Skip to content

Commit b62def5

Browse files
feat: support for 0.14.x
1 parent 77d6edb commit b62def5

File tree

8 files changed

+166
-96
lines changed

8 files changed

+166
-96
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-apple.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-apple.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-apple/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-apple/releases).**
1111

1212
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1313

@@ -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: "0.4.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "0.5.0"),
3535
],
3636
```
3737

@@ -42,9 +42,7 @@ Then add it to your target:
4242
.target(
4343
name: "YourAppTarget",
4444
dependencies: [
45-
.product(name: "
46-
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
47-
", package: "sdk-for-apple")
45+
.product(name: "", package: "sdk-for-apple")
4846
]
4947
),
5048
```

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:swiftclient:0.4.0",
23+
"x-sdk-version": "appwrite:swiftclient: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
@@ -76,32 +76,6 @@ open class Account: Service {
7676
)
7777
}
7878

79-
///
80-
/// Delete Account
81-
///
82-
/// Delete a currently logged in user account. Behind the scene, the user
83-
/// record is not deleted but permanently blocked from any access. This is done
84-
/// to avoid deleted accounts being overtaken by new users with the same email
85-
/// address. Any user-related resources like documents or storage files should
86-
/// be deleted separately.
87-
///
88-
/// @throws Exception
89-
/// @return array
90-
///
91-
open func delete(
92-
) async throws -> Any {
93-
let path: String = "/account"
94-
let params: [String: Any?] = [:]
95-
let headers: [String: String] = [
96-
"content-type": "application/json"
97-
]
98-
return try await client.call(
99-
method: "DELETE",
100-
path: path,
101-
headers: headers,
102-
params: params )
103-
}
104-
10579
///
10680
/// Update Account Email
10781
///
@@ -245,7 +219,7 @@ open class Account: Service {
245219
///
246220
/// Update currently logged in user password. For validation, user is required
247221
/// to pass in the new password, and the old password. For users created with
248-
/// OAuth and Team Invites, oldPassword is optional.
222+
/// OAuth, Team Invites and Magic URL, oldPassword is optional.
249223
///
250224
/// @param String password
251225
/// @param String oldPassword
@@ -725,6 +699,10 @@ open class Account: Service {
725699
///
726700
/// Update Session (Refresh Tokens)
727701
///
702+
/// Access tokens have limited lifespan and expire to mitigate security risks.
703+
/// If session was created using an OAuth provider, this route can be used to
704+
/// "refresh" the access token.
705+
///
728706
/// @param String sessionId
729707
/// @throws Exception
730708
/// @return array
@@ -784,6 +762,35 @@ open class Account: Service {
784762
params: params )
785763
}
786764

765+
///
766+
/// Update Account Status
767+
///
768+
/// Block the currently logged in user account. Behind the scene, the user
769+
/// record is not deleted but permanently blocked from any access. To
770+
/// completely delete a user, use the Users API instead.
771+
///
772+
/// @throws Exception
773+
/// @return array
774+
///
775+
open func updateStatus(
776+
) async throws -> AppwriteModels.User {
777+
let path: String = "/account/status"
778+
let params: [String: Any?] = [:]
779+
let headers: [String: String] = [
780+
"content-type": "application/json"
781+
]
782+
let converter: ([String: Any]) -> AppwriteModels.User = { dict in
783+
return AppwriteModels.User.from(map: dict)
784+
}
785+
return try await client.call(
786+
method: "PATCH",
787+
path: path,
788+
headers: headers,
789+
params: params,
790+
converter: converter
791+
)
792+
}
793+
787794
///
788795
/// Create Email Verification
789796
///
@@ -930,33 +937,6 @@ open class Account: Service {
930937
}
931938
}
932939

933-
///
934-
/// Delete Account
935-
///
936-
/// Delete a currently logged in user account. Behind the scene, the user
937-
/// record is not deleted but permanently blocked from any access. This is done
938-
/// to avoid deleted accounts being overtaken by new users with the same email
939-
/// address. Any user-related resources like documents or storage files should
940-
/// be deleted separately.
941-
///
942-
/// @throws Exception
943-
/// @return array
944-
///
945-
@available(*, deprecated, message: "Use the async overload instead")
946-
open func delete(
947-
completion: ((Result<Any, AppwriteError>) -> Void)? = nil
948-
) {
949-
Task {
950-
do {
951-
let result = try await delete(
952-
)
953-
completion?(.success(result))
954-
} catch {
955-
completion?(.failure(error as! AppwriteError))
956-
}
957-
}
958-
}
959-
960940
///
961941
/// Update Account Email
962942
///
@@ -1081,7 +1061,7 @@ open class Account: Service {
10811061
///
10821062
/// Update currently logged in user password. For validation, user is required
10831063
/// to pass in the new password, and the old password. For users created with
1084-
/// OAuth and Team Invites, oldPassword is optional.
1064+
/// OAuth, Team Invites and Magic URL, oldPassword is optional.
10851065
///
10861066
/// @param String password
10871067
/// @param String oldPassword
@@ -1500,6 +1480,10 @@ open class Account: Service {
15001480
///
15011481
/// Update Session (Refresh Tokens)
15021482
///
1483+
/// Access tokens have limited lifespan and expire to mitigate security risks.
1484+
/// If session was created using an OAuth provider, this route can be used to
1485+
/// "refresh" the access token.
1486+
///
15031487
/// @param String sessionId
15041488
/// @throws Exception
15051489
/// @return array
@@ -1550,6 +1534,31 @@ open class Account: Service {
15501534
}
15511535
}
15521536

1537+
///
1538+
/// Update Account Status
1539+
///
1540+
/// Block the currently logged in user account. Behind the scene, the user
1541+
/// record is not deleted but permanently blocked from any access. To
1542+
/// completely delete a user, use the Users API instead.
1543+
///
1544+
/// @throws Exception
1545+
/// @return array
1546+
///
1547+
@available(*, deprecated, message: "Use the async overload instead")
1548+
open func updateStatus(
1549+
completion: ((Result<AppwriteModels.User, AppwriteError>) -> Void)? = nil
1550+
) {
1551+
Task {
1552+
do {
1553+
let result = try await updateStatus(
1554+
)
1555+
completion?(.success(result))
1556+
} catch {
1557+
completion?(.failure(error as! AppwriteError))
1558+
}
1559+
}
1560+
}
1561+
15531562
///
15541563
/// Create Email Verification
15551564
///

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
@@ -49,6 +54,12 @@ open class Avatars: Service {
4954
/// The credit card endpoint will return you the icon of the credit card
5055
/// provider you need. Use width, height and quality arguments to change the
5156
/// output settings.
57+
///
58+
/// When one dimension is specified and the other is 0, the image is scaled
59+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
60+
/// image at source quality. If dimensions are not specified, the default size
61+
/// of image returned is 100x100px.
62+
///
5263
///
5364
/// @param String code
5465
/// @param Int width
@@ -113,6 +124,12 @@ open class Avatars: Service {
113124
/// You can use this endpoint to show different country flags icons to your
114125
/// users. The code argument receives the 2 letter country code. Use width,
115126
/// height and quality arguments to change the output settings.
127+
///
128+
/// When one dimension is specified and the other is 0, the image is scaled
129+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
130+
/// image at source quality. If dimensions are not specified, the default size
131+
/// of image returned is 100x100px.
132+
///
116133
///
117134
/// @param String code
118135
/// @param Int width
@@ -152,6 +169,12 @@ open class Avatars: Service {
152169
/// you want. This endpoint is very useful if you need to crop and display
153170
/// remote images in your app or in case you want to make sure a 3rd party
154171
/// image is properly served using a TLS protocol.
172+
///
173+
/// When one dimension is specified and the other is 0, the image is scaled
174+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
175+
/// image at source quality. If dimensions are not specified, the default size
176+
/// of image returned is 400x400px.
177+
///
155178
///
156179
/// @param String url
157180
/// @param Int width
@@ -191,6 +214,12 @@ open class Avatars: Service {
191214
/// default, a random theme will be selected. The random theme will persist for
192215
/// the user's initials when reloading the same theme will always return for
193216
/// the same initials.
217+
///
218+
/// When one dimension is specified and the other is 0, the image is scaled
219+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
220+
/// image at source quality. If dimensions are not specified, the default size
221+
/// of image returned is 100x100px.
222+
///
194223
///
195224
/// @param String name
196225
/// @param Int width
@@ -228,6 +257,7 @@ open class Avatars: Service {
228257
///
229258
/// Converts a given plain text to a QR code image. You can use the query
230259
/// parameters to change the size and style of the resulting image.
260+
///
231261
///
232262
/// @param String text
233263
/// @param Int size
@@ -262,9 +292,14 @@ open class Avatars: Service {
262292
/// Get Browser Icon
263293
///
264294
/// You can use this endpoint to show different browser icons to your users.
265-
/// The code argument receives the browser code as it appears in your user
266-
/// /account/sessions endpoint. Use width, height and quality arguments to
267-
/// change the output settings.
295+
/// The code argument receives the browser code as it appears in your user [GET
296+
/// /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
297+
/// width, height and quality arguments to change the output settings.
298+
///
299+
/// When one dimension is specified and the other is 0, the image is scaled
300+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
301+
/// image at source quality. If dimensions are not specified, the default size
302+
/// of image returned is 100x100px.
268303
///
269304
/// @param String code
270305
/// @param Int width
@@ -302,6 +337,12 @@ open class Avatars: Service {
302337
/// The credit card endpoint will return you the icon of the credit card
303338
/// provider you need. Use width, height and quality arguments to change the
304339
/// output settings.
340+
///
341+
/// When one dimension is specified and the other is 0, the image is scaled
342+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
343+
/// image at source quality. If dimensions are not specified, the default size
344+
/// of image returned is 100x100px.
345+
///
305346
///
306347
/// @param String code
307348
/// @param Int width
@@ -367,6 +408,12 @@ open class Avatars: Service {
367408
/// You can use this endpoint to show different country flags icons to your
368409
/// users. The code argument receives the 2 letter country code. Use width,
369410
/// height and quality arguments to change the output settings.
411+
///
412+
/// When one dimension is specified and the other is 0, the image is scaled
413+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
414+
/// image at source quality. If dimensions are not specified, the default size
415+
/// of image returned is 100x100px.
416+
///
370417
///
371418
/// @param String code
372419
/// @param Int width
@@ -405,6 +452,12 @@ open class Avatars: Service {
405452
/// you want. This endpoint is very useful if you need to crop and display
406453
/// remote images in your app or in case you want to make sure a 3rd party
407454
/// image is properly served using a TLS protocol.
455+
///
456+
/// When one dimension is specified and the other is 0, the image is scaled
457+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
458+
/// image at source quality. If dimensions are not specified, the default size
459+
/// of image returned is 400x400px.
460+
///
408461
///
409462
/// @param String url
410463
/// @param Int width
@@ -446,6 +499,12 @@ open class Avatars: Service {
446499
/// default, a random theme will be selected. The random theme will persist for
447500
/// the user's initials when reloading the same theme will always return for
448501
/// the same initials.
502+
///
503+
/// When one dimension is specified and the other is 0, the image is scaled
504+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
505+
/// image at source quality. If dimensions are not specified, the default size
506+
/// of image returned is 100x100px.
507+
///
449508
///
450509
/// @param String name
451510
/// @param Int width
@@ -485,6 +544,7 @@ open class Avatars: Service {
485544
///
486545
/// Converts a given plain text to a QR code image. You can use the query
487546
/// parameters to change the size and style of the resulting image.
547+
///
488548
///
489549
/// @param String text
490550
/// @param Int size

Sources/Appwrite/Services/Database.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ open class Database: Service {
204204
///
205205
/// Delete Document
206206
///
207-
/// Delete a document by its unique ID. This endpoint deletes only the parent
208-
/// documents, its attributes and relations to other documents. Child documents
209-
/// **will not** be deleted.
207+
/// Delete a document by its unique ID.
210208
///
211209
/// @param String collectionId
212210
/// @param String documentId
@@ -401,9 +399,7 @@ open class Database: Service {
401399
///
402400
/// Delete Document
403401
///
404-
/// Delete a document by its unique ID. This endpoint deletes only the parent
405-
/// documents, its attributes and relations to other documents. Child documents
406-
/// **will not** be deleted.
402+
/// Delete a document by its unique ID.
407403
///
408404
/// @param String collectionId
409405
/// @param String documentId

0 commit comments

Comments
 (0)