Skip to content

Commit 11745a1

Browse files
feat: support for 0.14.x
1 parent 8ee6b77 commit 11745a1

File tree

12 files changed

+246
-157
lines changed

12 files changed

+246
-157
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
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-0.13.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.14.0-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)
99

10-
**This SDK is compatible with Appwrite server version 0.13.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
10+
**This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
1111

1212
> This is the Swift SDK for integrating with Appwrite from your Swift server-side code. If you're looking for the Apple SDK you should check [appwrite/sdk-for-apple](https://github.com/appwrite/sdk-for-apple)
1313
@@ -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: "0.4.0"),
36+
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "0.5.0"),
3737
],
3838
```
3939

@@ -44,9 +44,7 @@ Then add it to your target:
4444
.target(
4545
name: "YourAppTarget",
4646
dependencies: [
47-
.product(name: "
48-
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/dlohani/Documents/projects/appwrite/appwrite_src/vendor/appwrite/sdk-generator/src/SDK/SDK.php on line 746
49-
", package: "sdk-for-swift")
47+
.product(name: "", package: "sdk-for-swift")
5048
]
5149
),
5250
```

Sources/Appwrite/Client.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open class Client {
2020

2121
open var headers: [String: String] = [
2222
"content-type": "",
23-
"x-sdk-version": "appwrite:swift:0.4.0",
23+
"x-sdk-version": "appwrite:swift:0.5.0",
2424
"X-Appwrite-Response-Format": "0.13.0"
2525
]
2626

Sources/Appwrite/Services/Account.swift

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,6 @@ open class Account: Service {
3131
)
3232
}
3333

34-
///
35-
/// Delete Account
36-
///
37-
/// Delete a currently logged in user account. Behind the scene, the user
38-
/// record is not deleted but permanently blocked from any access. This is done
39-
/// to avoid deleted accounts being overtaken by new users with the same email
40-
/// address. Any user-related resources like documents or storage files should
41-
/// be deleted separately.
42-
///
43-
/// @throws Exception
44-
/// @return array
45-
///
46-
open func delete(
47-
) async throws -> Any {
48-
let path: String = "/account"
49-
let params: [String: Any?] = [:]
50-
let headers: [String: String] = [
51-
"content-type": "application/json"
52-
]
53-
return try await client.call(
54-
method: "DELETE",
55-
path: path,
56-
headers: headers,
57-
params: params )
58-
}
59-
6034
///
6135
/// Update Account Email
6236
///
@@ -169,7 +143,7 @@ open class Account: Service {
169143
///
170144
/// Update currently logged in user password. For validation, user is required
171145
/// to pass in the new password, and the old password. For users created with
172-
/// OAuth and Team Invites, oldPassword is optional.
146+
/// OAuth, Team Invites and Magic URL, oldPassword is optional.
173147
///
174148
/// @param String password
175149
/// @param String oldPassword
@@ -437,6 +411,10 @@ open class Account: Service {
437411
///
438412
/// Update Session (Refresh Tokens)
439413
///
414+
/// Access tokens have limited lifespan and expire to mitigate security risks.
415+
/// If session was created using an OAuth provider, this route can be used to
416+
/// "refresh" the access token.
417+
///
440418
/// @param String sessionId
441419
/// @throws Exception
442420
/// @return array
@@ -496,6 +474,35 @@ open class Account: Service {
496474
params: params )
497475
}
498476

477+
///
478+
/// Update Account Status
479+
///
480+
/// Block the currently logged in user account. Behind the scene, the user
481+
/// record is not deleted but permanently blocked from any access. To
482+
/// completely delete a user, use the Users API instead.
483+
///
484+
/// @throws Exception
485+
/// @return array
486+
///
487+
open func updateStatus(
488+
) async throws -> AppwriteModels.User {
489+
let path: String = "/account/status"
490+
let params: [String: Any?] = [:]
491+
let headers: [String: String] = [
492+
"content-type": "application/json"
493+
]
494+
let converter: ([String: Any]) -> AppwriteModels.User = { dict in
495+
return AppwriteModels.User.from(map: dict)
496+
}
497+
return try await client.call(
498+
method: "PATCH",
499+
path: path,
500+
headers: headers,
501+
params: params,
502+
converter: converter
503+
)
504+
}
505+
499506
///
500507
/// Create Email Verification
501508
///
@@ -602,33 +609,6 @@ open class Account: Service {
602609
}
603610
}
604611

605-
///
606-
/// Delete Account
607-
///
608-
/// Delete a currently logged in user account. Behind the scene, the user
609-
/// record is not deleted but permanently blocked from any access. This is done
610-
/// to avoid deleted accounts being overtaken by new users with the same email
611-
/// address. Any user-related resources like documents or storage files should
612-
/// be deleted separately.
613-
///
614-
/// @throws Exception
615-
/// @return array
616-
///
617-
@available(*, deprecated, message: "Use the async overload instead")
618-
open func delete(
619-
completion: ((Result<Any, AppwriteError>) -> Void)? = nil
620-
) {
621-
Task {
622-
do {
623-
let result = try await delete(
624-
)
625-
completion?(.success(result))
626-
} catch {
627-
completion?(.failure(error as! AppwriteError))
628-
}
629-
}
630-
}
631-
632612
///
633613
/// Update Account Email
634614
///
@@ -726,7 +706,7 @@ open class Account: Service {
726706
///
727707
/// Update currently logged in user password. For validation, user is required
728708
/// to pass in the new password, and the old password. For users created with
729-
/// OAuth and Team Invites, oldPassword is optional.
709+
/// OAuth, Team Invites and Magic URL, oldPassword is optional.
730710
///
731711
/// @param String password
732712
/// @param String oldPassword
@@ -960,6 +940,10 @@ open class Account: Service {
960940
///
961941
/// Update Session (Refresh Tokens)
962942
///
943+
/// Access tokens have limited lifespan and expire to mitigate security risks.
944+
/// If session was created using an OAuth provider, this route can be used to
945+
/// "refresh" the access token.
946+
///
963947
/// @param String sessionId
964948
/// @throws Exception
965949
/// @return array
@@ -1010,6 +994,31 @@ open class Account: Service {
1010994
}
1011995
}
1012996

997+
///
998+
/// Update Account Status
999+
///
1000+
/// Block the currently logged in user account. Behind the scene, the user
1001+
/// record is not deleted but permanently blocked from any access. To
1002+
/// completely delete a user, use the Users API instead.
1003+
///
1004+
/// @throws Exception
1005+
/// @return array
1006+
///
1007+
@available(*, deprecated, message: "Use the async overload instead")
1008+
open func updateStatus(
1009+
completion: ((Result<AppwriteModels.User, AppwriteError>) -> Void)? = nil
1010+
) {
1011+
Task {
1012+
do {
1013+
let result = try await updateStatus(
1014+
)
1015+
completion?(.success(result))
1016+
} catch {
1017+
completion?(.failure(error as! AppwriteError))
1018+
}
1019+
}
1020+
}
1021+
10131022
///
10141023
/// Create Email Verification
10151024
///

Sources/Appwrite/Services/Avatars.swift

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ open class Avatars: Service {
88
/// Get Browser Icon
99
///
1010
/// You can use this endpoint to show different browser icons to your users.
11-
/// The code argument receives the browser code as it appears in your user
12-
/// /account/sessions endpoint. Use width, height and quality arguments to
13-
/// change the output settings.
11+
/// The code argument receives the browser code as it appears in your user [GET
12+
/// /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
13+
/// width, height and quality arguments to change the output settings.
14+
///
15+
/// When one dimension is specified and the other is 0, the image is scaled
16+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
17+
/// image at source quality. If dimensions are not specified, the default size
18+
/// of image returned is 100x100px.
1419
///
1520
/// @param String code
1621
/// @param Int width
@@ -50,6 +55,12 @@ open class Avatars: Service {
5055
/// The credit card endpoint will return you the icon of the credit card
5156
/// provider you need. Use width, height and quality arguments to change the
5257
/// output settings.
58+
///
59+
/// When one dimension is specified and the other is 0, the image is scaled
60+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
61+
/// image at source quality. If dimensions are not specified, the default size
62+
/// of image returned is 100x100px.
63+
///
5364
///
5465
/// @param String code
5566
/// @param Int width
@@ -116,6 +127,12 @@ open class Avatars: Service {
116127
/// You can use this endpoint to show different country flags icons to your
117128
/// users. The code argument receives the 2 letter country code. Use width,
118129
/// height and quality arguments to change the output settings.
130+
///
131+
/// When one dimension is specified and the other is 0, the image is scaled
132+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
133+
/// image at source quality. If dimensions are not specified, the default size
134+
/// of image returned is 100x100px.
135+
///
119136
///
120137
/// @param String code
121138
/// @param Int width
@@ -156,6 +173,12 @@ open class Avatars: Service {
156173
/// you want. This endpoint is very useful if you need to crop and display
157174
/// remote images in your app or in case you want to make sure a 3rd party
158175
/// image is properly served using a TLS protocol.
176+
///
177+
/// When one dimension is specified and the other is 0, the image is scaled
178+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
179+
/// image at source quality. If dimensions are not specified, the default size
180+
/// of image returned is 400x400px.
181+
///
159182
///
160183
/// @param String url
161184
/// @param Int width
@@ -196,6 +219,12 @@ open class Avatars: Service {
196219
/// default, a random theme will be selected. The random theme will persist for
197220
/// the user's initials when reloading the same theme will always return for
198221
/// the same initials.
222+
///
223+
/// When one dimension is specified and the other is 0, the image is scaled
224+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
225+
/// image at source quality. If dimensions are not specified, the default size
226+
/// of image returned is 100x100px.
227+
///
199228
///
200229
/// @param String name
201230
/// @param Int width
@@ -234,6 +263,7 @@ open class Avatars: Service {
234263
///
235264
/// Converts a given plain text to a QR code image. You can use the query
236265
/// parameters to change the size and style of the resulting image.
266+
///
237267
///
238268
/// @param String text
239269
/// @param Int size
@@ -269,9 +299,14 @@ open class Avatars: Service {
269299
/// Get Browser Icon
270300
///
271301
/// You can use this endpoint to show different browser icons to your users.
272-
/// The code argument receives the browser code as it appears in your user
273-
/// /account/sessions endpoint. Use width, height and quality arguments to
274-
/// change the output settings.
302+
/// The code argument receives the browser code as it appears in your user [GET
303+
/// /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
304+
/// width, height and quality arguments to change the output settings.
305+
///
306+
/// When one dimension is specified and the other is 0, the image is scaled
307+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
308+
/// image at source quality. If dimensions are not specified, the default size
309+
/// of image returned is 100x100px.
275310
///
276311
/// @param String code
277312
/// @param Int width
@@ -309,6 +344,12 @@ open class Avatars: Service {
309344
/// The credit card endpoint will return you the icon of the credit card
310345
/// provider you need. Use width, height and quality arguments to change the
311346
/// output settings.
347+
///
348+
/// When one dimension is specified and the other is 0, the image is scaled
349+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
350+
/// image at source quality. If dimensions are not specified, the default size
351+
/// of image returned is 100x100px.
352+
///
312353
///
313354
/// @param String code
314355
/// @param Int width
@@ -374,6 +415,12 @@ open class Avatars: Service {
374415
/// You can use this endpoint to show different country flags icons to your
375416
/// users. The code argument receives the 2 letter country code. Use width,
376417
/// height and quality arguments to change the output settings.
418+
///
419+
/// When one dimension is specified and the other is 0, the image is scaled
420+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
421+
/// image at source quality. If dimensions are not specified, the default size
422+
/// of image returned is 100x100px.
423+
///
377424
///
378425
/// @param String code
379426
/// @param Int width
@@ -412,6 +459,12 @@ open class Avatars: Service {
412459
/// you want. This endpoint is very useful if you need to crop and display
413460
/// remote images in your app or in case you want to make sure a 3rd party
414461
/// image is properly served using a TLS protocol.
462+
///
463+
/// When one dimension is specified and the other is 0, the image is scaled
464+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
465+
/// image at source quality. If dimensions are not specified, the default size
466+
/// of image returned is 400x400px.
467+
///
415468
///
416469
/// @param String url
417470
/// @param Int width
@@ -453,6 +506,12 @@ open class Avatars: Service {
453506
/// default, a random theme will be selected. The random theme will persist for
454507
/// the user's initials when reloading the same theme will always return for
455508
/// the same initials.
509+
///
510+
/// When one dimension is specified and the other is 0, the image is scaled
511+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
512+
/// image at source quality. If dimensions are not specified, the default size
513+
/// of image returned is 100x100px.
514+
///
456515
///
457516
/// @param String name
458517
/// @param Int width
@@ -492,6 +551,7 @@ open class Avatars: Service {
492551
///
493552
/// Converts a given plain text to a QR code image. You can use the query
494553
/// parameters to change the size and style of the resulting image.
554+
///
495555
///
496556
/// @param String text
497557
/// @param Int size

Sources/Appwrite/Services/Database.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,7 @@ open class Database: Service {
896896
///
897897
/// Delete Document
898898
///
899-
/// Delete a document by its unique ID. This endpoint deletes only the parent
900-
/// documents, its attributes and relations to other documents. Child documents
901-
/// **will not** be deleted.
899+
/// Delete a document by its unique ID.
902900
///
903901
/// @param String collectionId
904902
/// @param String documentId
@@ -1821,9 +1819,7 @@ open class Database: Service {
18211819
///
18221820
/// Delete Document
18231821
///
1824-
/// Delete a document by its unique ID. This endpoint deletes only the parent
1825-
/// documents, its attributes and relations to other documents. Child documents
1826-
/// **will not** be deleted.
1822+
/// Delete a document by its unique ID.
18271823
///
18281824
/// @param String collectionId
18291825
/// @param String documentId

0 commit comments

Comments
 (0)