Skip to content

Commit f7fda25

Browse files
committed
fix: minor bugs
1 parent 23eef4b commit f7fda25

File tree

12 files changed

+47
-55
lines changed

12 files changed

+47
-55
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -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: "5.0.1"),
36+
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "5.0.2"),
3737
],
3838
```
3939

Sources/Appwrite/Client.swift

Lines changed: 1 addition & 1 deletion
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": "5.0.1",
24+
"x-sdk-version": "5.0.2",
2525
"x-appwrite-response-format": "1.5.0"
2626
]
2727

Sources/Appwrite/Services/Account.swift

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ open class Account: Service {
406406
///
407407
/// Add an authenticator app to be used as an MFA factor. Verify the
408408
/// authenticator using the [verify
409-
/// authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
409+
/// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator)
410410
/// method.
411411
///
412412
/// @param AppwriteEnums.AuthenticatorType type
@@ -442,8 +442,8 @@ open class Account: Service {
442442
/// Verify Authenticator
443443
///
444444
/// Verify an authenticator app after adding it using the [add
445-
/// authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
446-
/// method.
445+
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
446+
/// method. add
447447
///
448448
/// @param AppwriteEnums.AuthenticatorType type
449449
/// @param String otp
@@ -483,8 +483,8 @@ open class Account: Service {
483483
/// Verify Authenticator
484484
///
485485
/// Verify an authenticator app after adding it using the [add
486-
/// authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
487-
/// method.
486+
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
487+
/// method. add
488488
///
489489
/// @param AppwriteEnums.AuthenticatorType type
490490
/// @param String otp
@@ -512,11 +512,10 @@ open class Account: Service {
512512
/// @throws Exception
513513
/// @return array
514514
///
515-
open func deleteMfaAuthenticator<T>(
515+
open func deleteMfaAuthenticator(
516516
type: AppwriteEnums.AuthenticatorType,
517-
otp: String,
518-
nestedType: T.Type
519-
) async throws -> AppwriteModels.User<T> {
517+
otp: String
518+
) async throws -> Any {
520519
let apiPath: String = "/account/mfa/authenticators/{type}"
521520
.replacingOccurrences(of: "{type}", with: type.rawValue)
522521

@@ -528,38 +527,11 @@ open class Account: Service {
528527
"content-type": "application/json"
529528
]
530529

531-
let converter: (Any) -> AppwriteModels.User<T> = { response in
532-
return AppwriteModels.User.from(map: response as! [String: Any])
533-
}
534-
535530
return try await client.call(
536531
method: "DELETE",
537532
path: apiPath,
538533
headers: apiHeaders,
539-
params: apiParams,
540-
converter: converter
541-
)
542-
}
543-
544-
///
545-
/// Delete Authenticator
546-
///
547-
/// Delete an authenticator for a user by ID.
548-
///
549-
/// @param AppwriteEnums.AuthenticatorType type
550-
/// @param String otp
551-
/// @throws Exception
552-
/// @return array
553-
///
554-
open func deleteMfaAuthenticator(
555-
type: AppwriteEnums.AuthenticatorType,
556-
otp: String
557-
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
558-
return try await deleteMfaAuthenticator(
559-
type: type,
560-
otp: otp,
561-
nestedType: [String: AnyCodable].self
562-
)
534+
params: apiParams )
563535
}
564536

565537
///

Sources/Appwrite/Services/Messaging.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ open class Messaging: Service {
131131
/// @param [String] cc
132132
/// @param [String] bcc
133133
/// @param String scheduledAt
134+
/// @param [String] attachments
134135
/// @throws Exception
135136
/// @return array
136137
///
@@ -145,7 +146,8 @@ open class Messaging: Service {
145146
html: Bool? = nil,
146147
cc: [String]? = nil,
147148
bcc: [String]? = nil,
148-
scheduledAt: String? = nil
149+
scheduledAt: String? = nil,
150+
attachments: [String]? = nil
149151
) async throws -> AppwriteModels.Message {
150152
let apiPath: String = "/messaging/messages/email/{messageId}"
151153
.replacingOccurrences(of: "{messageId}", with: messageId)
@@ -160,7 +162,8 @@ open class Messaging: Service {
160162
"html": html,
161163
"cc": cc,
162164
"bcc": bcc,
163-
"scheduledAt": scheduledAt
165+
"scheduledAt": scheduledAt,
166+
"attachments": attachments
164167
]
165168

166169
let apiHeaders: [String: String] = [

Sources/Appwrite/Services/Users.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,11 +2065,11 @@ open class Users: Service {
20652065
///
20662066
/// Create token
20672067
///
2068-
/// Returns a token with a secret key for creating a session. If the provided
2069-
/// user ID has not be registered, a new user will be created. Use the returned
2070-
/// user ID and secret and submit a request to the [PUT
2071-
/// /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession)
2068+
/// Returns a token with a secret key for creating a session. Use the user ID
2069+
/// and secret and submit a request to the [PUT
2070+
/// /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
20722071
/// endpoint to complete the login process.
2072+
///
20732073
///
20742074
/// @param String userId
20752075
/// @param Int length

Sources/AppwriteEnums/CreditCard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public enum CreditCard: String, Codable {
44
case americanExpress = "amex"
55
case argencard = "argencard"
66
case cabal = "cabal"
7-
case consosud = "censosud"
7+
case cencosud = "cencosud"
88
case dinersClub = "diners"
99
case discover = "discover"
1010
case elo = "elo"

Sources/AppwriteEnums/Flag.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public enum Flag: String, Codable {
142142
case palau = "pw"
143143
case papuaNewGuinea = "pg"
144144
case poland = "pl"
145+
case frenchPolynesia = "pf"
145146
case northKorea = "kp"
146147
case portugal = "pt"
147148
case paraguay = "py"

Sources/AppwriteEnums/Runtime.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public enum Runtime: String, Codable {
2020
case python310 = "python-3.10"
2121
case python311 = "python-3.11"
2222
case python312 = "python-3.12"
23+
case pythonMl311 = "python-ml-3.11"
2324
case deno140 = "deno-1.40"
2425
case dart215 = "dart-2.15"
2526
case dart216 = "dart-2.16"

Sources/AppwriteModels/MfaFactors.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,46 @@ import JSONCodable
44
/// MFAFactors
55
public class MfaFactors {
66

7-
/// TOTP
7+
/// Can TOTP be used for MFA challenge for this account.
88
public let totp: Bool
99

10-
/// Phone
10+
/// Can phone (SMS) be used for MFA challenge for this account.
1111
public let phone: Bool
1212

13-
/// Email
13+
/// Can email be used for MFA challenge for this account.
1414
public let email: Bool
1515

16+
/// Can recovery code be used for MFA challenge for this account.
17+
public let recoveryCode: Bool
18+
1619

1720
init(
1821
totp: Bool,
1922
phone: Bool,
20-
email: Bool
23+
email: Bool,
24+
recoveryCode: Bool
2125
) {
2226
self.totp = totp
2327
self.phone = phone
2428
self.email = email
29+
self.recoveryCode = recoveryCode
2530
}
2631

2732
public func toMap() -> [String: Any] {
2833
return [
2934
"totp": totp as Any,
3035
"phone": phone as Any,
31-
"email": email as Any
36+
"email": email as Any,
37+
"recoveryCode": recoveryCode as Any
3238
]
3339
}
3440

3541
public static func from(map: [String: Any] ) -> MfaFactors {
3642
return MfaFactors(
3743
totp: map["totp"] as! Bool,
3844
phone: map["phone"] as! Bool,
39-
email: map["email"] as! Bool
45+
email: map["email"] as! Bool,
46+
recoveryCode: map["recoveryCode"] as! Bool
4047
)
4148
}
4249
}

Sources/AppwriteModels/Session.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public class Session {
1010
/// Session creation date in ISO 8601 format.
1111
public let createdAt: String
1212

13+
/// Session update date in ISO 8601 format.
14+
public let updatedAt: String
15+
1316
/// User ID.
1417
public let userId: String
1518

@@ -92,6 +95,7 @@ public class Session {
9295
init(
9396
id: String,
9497
createdAt: String,
98+
updatedAt: String,
9599
userId: String,
96100
expire: String,
97101
provider: String,
@@ -121,6 +125,7 @@ public class Session {
121125
) {
122126
self.id = id
123127
self.createdAt = createdAt
128+
self.updatedAt = updatedAt
124129
self.userId = userId
125130
self.expire = expire
126131
self.provider = provider
@@ -153,6 +158,7 @@ public class Session {
153158
return [
154159
"$id": id as Any,
155160
"$createdAt": createdAt as Any,
161+
"$updatedAt": updatedAt as Any,
156162
"userId": userId as Any,
157163
"expire": expire as Any,
158164
"provider": provider as Any,
@@ -186,6 +192,7 @@ public class Session {
186192
return Session(
187193
id: map["$id"] as! String,
188194
createdAt: map["$createdAt"] as! String,
195+
updatedAt: map["$updatedAt"] as! String,
189196
userId: map["userId"] as! String,
190197
expire: map["expire"] as! String,
191198
provider: map["provider"] as! String,

docs/examples/account/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 account = Account(client)
1010

11-
let user = try await account.deleteMfaAuthenticator(
11+
let result = try await account.deleteMfaAuthenticator(
1212
type: .totp,
1313
otp: "<OTP>"
1414
)

docs/examples/messaging/update-email.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let message = try await messaging.updateEmail(
1818
html: false, // optional
1919
cc: [], // optional
2020
bcc: [], // optional
21-
scheduledAt: "" // optional
21+
scheduledAt: "", // optional
22+
attachments: [] // optional
2223
)
2324

0 commit comments

Comments
 (0)