Skip to content

Commit 37a3867

Browse files
authored
Merge pull request #32 from appwrite/dev
update to appwrite 1.3.0
2 parents 5b6babb + 76b7a07 commit 37a3867

28 files changed

+676
-96
lines changed

README.md

Lines changed: 4 additions & 4 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-1.2.1-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.3.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 1.2.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 1.3.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

@@ -19,7 +19,7 @@ Appwrite is an open-source backend as a service server that abstract and simplif
1919

2020
The Appwrite Swift SDK is available via Swift Package Manager. In order to use the Appwrite Swift SDK from Xcode, select File > **Add Packages**
2121

22-
In the dialog that appears, enter the Appwrite Swift SDK [package URL](https://github.com/appwrite/sdk-for-apple.git) in the search field. Once found, select `sdk-for-apple`.
22+
In the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-apple.git) in the search field. Once found, select `sdk-for-apple`.
2323

2424
On the right, select your version rules and ensure your desired target is selected in the **Add to Project** field.
2525

@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "https://github.com/appwrite/sdk-for-apple.git", from: "1.2.3"),
34+
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "2.0.0"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open class Client {
2323
"x-sdk-name": "Apple",
2424
"x-sdk-platform": "client",
2525
"x-sdk-language": "apple",
26-
"x-sdk-version": "1.2.3",
26+
"x-sdk-version": "2.0.0",
2727
"X-Appwrite-Response-Format": "1.0.0"
2828
]
2929

Sources/Appwrite/Query.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,38 @@ public class Query {
2424
buildQueryWhere(attribute, is: "greaterThanEqual", to: value)
2525
}
2626

27+
public static func isNull(_ attribute: String) -> String {
28+
"isNull(\"\(attribute)\")"
29+
}
30+
31+
public static func isNotNull(_ attribute: String) -> String {
32+
"isNotNull(\"\(attribute)\")"
33+
}
34+
35+
public static func between(_ attribute: String, start: Int, end: Int) -> String {
36+
buildQueryWhere(attribute, is: "between", to: [start, end])
37+
}
38+
39+
public static func between(_ attribute: String, start: Double, end: Double) -> String {
40+
buildQueryWhere(attribute, is: "between", to: [start, end])
41+
}
42+
43+
public static func between(_ attribute: String, start: String, end: String) -> String {
44+
buildQueryWhere(attribute, is: "between", to: [start, end])
45+
}
46+
47+
public static func startsWith(_ attribute: String, value: String) -> String {
48+
buildQueryWhere(attribute, is: "startsWith", to: value)
49+
}
50+
51+
public static func endsWith(_ attribute: String, value: String) -> String {
52+
buildQueryWhere(attribute, is: "endsWith", to: value)
53+
}
54+
55+
public static func select(_ attributes: [String]) -> String {
56+
"select([\(attributes.map { "\"\($0)\"" }.joined(separator: ","))])"
57+
}
58+
2759
public static func search(_ attribute: String, value: String) -> String {
2860
buildQueryWhere(attribute, is: "search", to: value)
2961
}

Sources/Appwrite/Services/Account.swift

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open class Account: Service {
1717
///
1818
open func get<T>(
1919
nestedType: T.Type
20-
) async throws -> AppwriteModels.Account<T> {
20+
) async throws -> AppwriteModels.User<T> {
2121
let path: String = "/account"
2222

2323
let params: [String: Any] = [:]
@@ -26,8 +26,8 @@ open class Account: Service {
2626
"content-type": "application/json"
2727
]
2828

29-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
30-
return AppwriteModels.Account.from(map: response as! [String: Any])
29+
let converter: (Any) -> AppwriteModels.User<T> = { response in
30+
return AppwriteModels.User.from(map: response as! [String: Any])
3131
}
3232

3333
return try await client.call(
@@ -48,7 +48,7 @@ open class Account: Service {
4848
/// @return array
4949
///
5050
open func get(
51-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
51+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
5252
return try await get(
5353
nestedType: [String: AnyCodable].self
5454
)
@@ -77,7 +77,7 @@ open class Account: Service {
7777
password: String,
7878
name: String? = nil,
7979
nestedType: T.Type
80-
) async throws -> AppwriteModels.Account<T> {
80+
) async throws -> AppwriteModels.User<T> {
8181
let path: String = "/account"
8282

8383
let params: [String: Any?] = [
@@ -91,8 +91,8 @@ open class Account: Service {
9191
"content-type": "application/json"
9292
]
9393

94-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
95-
return AppwriteModels.Account.from(map: response as! [String: Any])
94+
let converter: (Any) -> AppwriteModels.User<T> = { response in
95+
return AppwriteModels.User.from(map: response as! [String: Any])
9696
}
9797

9898
return try await client.call(
@@ -126,7 +126,7 @@ open class Account: Service {
126126
email: String,
127127
password: String,
128128
name: String? = nil
129-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
129+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
130130
return try await create(
131131
userId: userId,
132132
email: email,
@@ -157,7 +157,7 @@ open class Account: Service {
157157
email: String,
158158
password: String,
159159
nestedType: T.Type
160-
) async throws -> AppwriteModels.Account<T> {
160+
) async throws -> AppwriteModels.User<T> {
161161
let path: String = "/account/email"
162162

163163
let params: [String: Any?] = [
@@ -169,8 +169,8 @@ open class Account: Service {
169169
"content-type": "application/json"
170170
]
171171

172-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
173-
return AppwriteModels.Account.from(map: response as! [String: Any])
172+
let converter: (Any) -> AppwriteModels.User<T> = { response in
173+
return AppwriteModels.User.from(map: response as! [String: Any])
174174
}
175175

176176
return try await client.call(
@@ -202,7 +202,7 @@ open class Account: Service {
202202
open func updateEmail(
203203
email: String,
204204
password: String
205-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
205+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
206206
return try await updateEmail(
207207
email: email,
208208
password: password,
@@ -293,7 +293,7 @@ open class Account: Service {
293293
open func updateName<T>(
294294
name: String,
295295
nestedType: T.Type
296-
) async throws -> AppwriteModels.Account<T> {
296+
) async throws -> AppwriteModels.User<T> {
297297
let path: String = "/account/name"
298298

299299
let params: [String: Any?] = [
@@ -304,8 +304,8 @@ open class Account: Service {
304304
"content-type": "application/json"
305305
]
306306

307-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
308-
return AppwriteModels.Account.from(map: response as! [String: Any])
307+
let converter: (Any) -> AppwriteModels.User<T> = { response in
308+
return AppwriteModels.User.from(map: response as! [String: Any])
309309
}
310310

311311
return try await client.call(
@@ -328,7 +328,7 @@ open class Account: Service {
328328
///
329329
open func updateName(
330330
name: String
331-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
331+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
332332
return try await updateName(
333333
name: name,
334334
nestedType: [String: AnyCodable].self
@@ -351,7 +351,7 @@ open class Account: Service {
351351
password: String,
352352
oldPassword: String? = nil,
353353
nestedType: T.Type
354-
) async throws -> AppwriteModels.Account<T> {
354+
) async throws -> AppwriteModels.User<T> {
355355
let path: String = "/account/password"
356356

357357
let params: [String: Any?] = [
@@ -363,8 +363,8 @@ open class Account: Service {
363363
"content-type": "application/json"
364364
]
365365

366-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
367-
return AppwriteModels.Account.from(map: response as! [String: Any])
366+
let converter: (Any) -> AppwriteModels.User<T> = { response in
367+
return AppwriteModels.User.from(map: response as! [String: Any])
368368
}
369369

370370
return try await client.call(
@@ -391,7 +391,7 @@ open class Account: Service {
391391
open func updatePassword(
392392
password: String,
393393
oldPassword: String? = nil
394-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
394+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
395395
return try await updatePassword(
396396
password: password,
397397
oldPassword: oldPassword,
@@ -417,7 +417,7 @@ open class Account: Service {
417417
phone: String,
418418
password: String,
419419
nestedType: T.Type
420-
) async throws -> AppwriteModels.Account<T> {
420+
) async throws -> AppwriteModels.User<T> {
421421
let path: String = "/account/phone"
422422

423423
let params: [String: Any?] = [
@@ -429,8 +429,8 @@ open class Account: Service {
429429
"content-type": "application/json"
430430
]
431431

432-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
433-
return AppwriteModels.Account.from(map: response as! [String: Any])
432+
let converter: (Any) -> AppwriteModels.User<T> = { response in
433+
return AppwriteModels.User.from(map: response as! [String: Any])
434434
}
435435

436436
return try await client.call(
@@ -459,7 +459,7 @@ open class Account: Service {
459459
open func updatePhone(
460460
phone: String,
461461
password: String
462-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
462+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
463463
return try await updatePhone(
464464
phone: phone,
465465
password: password,
@@ -528,7 +528,7 @@ open class Account: Service {
528528
open func updatePrefs<T>(
529529
prefs: Any,
530530
nestedType: T.Type
531-
) async throws -> AppwriteModels.Account<T> {
531+
) async throws -> AppwriteModels.User<T> {
532532
let path: String = "/account/prefs"
533533

534534
let params: [String: Any?] = [
@@ -539,8 +539,8 @@ open class Account: Service {
539539
"content-type": "application/json"
540540
]
541541

542-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
543-
return AppwriteModels.Account.from(map: response as! [String: Any])
542+
let converter: (Any) -> AppwriteModels.User<T> = { response in
543+
return AppwriteModels.User.from(map: response as! [String: Any])
544544
}
545545

546546
return try await client.call(
@@ -565,7 +565,7 @@ open class Account: Service {
565565
///
566566
open func updatePrefs(
567567
prefs: Any
568-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
568+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
569569
return try await updatePrefs(
570570
prefs: prefs,
571571
nestedType: [String: AnyCodable].self
@@ -770,7 +770,7 @@ open class Account: Service {
770770
/// password combination. This route will create a new session for the user.
771771
///
772772
/// A user is limited to 10 active sessions at a time by default. [Learn more
773-
/// about session limits](/docs/authentication#limits).
773+
/// about session limits](/docs/authentication-security#limits).
774774
///
775775
/// @param String email
776776
/// @param String password
@@ -821,7 +821,7 @@ open class Account: Service {
821821
/// your Appwrite instance by default.
822822
///
823823
/// A user is limited to 10 active sessions at a time by default. [Learn more
824-
/// about session limits](/docs/authentication#limits).
824+
/// about session limits](/docs/authentication-security#limits).
825825
///
826826
/// @param String userId
827827
/// @param String email
@@ -923,7 +923,7 @@ open class Account: Service {
923923
/// user.
924924
///
925925
/// A user is limited to 10 active sessions at a time by default. [Learn more
926-
/// about session limits](/docs/authentication#limits).
926+
/// about session limits](/docs/authentication-security#limits).
927927
///
928928
///
929929
/// @param String provider
@@ -976,7 +976,7 @@ open class Account: Service {
976976
/// is valid for 15 minutes.
977977
///
978978
/// A user is limited to 10 active sessions at a time by default. [Learn more
979-
/// about session limits](/docs/authentication#limits).
979+
/// about session limits](/docs/authentication-security#limits).
980980
///
981981
/// @param String userId
982982
/// @param String phone
@@ -1167,7 +1167,7 @@ open class Account: Service {
11671167
///
11681168
open func updateStatus<T>(
11691169
nestedType: T.Type
1170-
) async throws -> AppwriteModels.Account<T> {
1170+
) async throws -> AppwriteModels.User<T> {
11711171
let path: String = "/account/status"
11721172

11731173
let params: [String: Any] = [:]
@@ -1176,8 +1176,8 @@ open class Account: Service {
11761176
"content-type": "application/json"
11771177
]
11781178

1179-
let converter: (Any) -> AppwriteModels.Account<T> = { response in
1180-
return AppwriteModels.Account.from(map: response as! [String: Any])
1179+
let converter: (Any) -> AppwriteModels.User<T> = { response in
1180+
return AppwriteModels.User.from(map: response as! [String: Any])
11811181
}
11821182

11831183
return try await client.call(
@@ -1200,7 +1200,7 @@ open class Account: Service {
12001200
/// @return array
12011201
///
12021202
open func updateStatus(
1203-
) async throws -> AppwriteModels.Account<[String: AnyCodable]> {
1203+
) async throws -> AppwriteModels.User<[String: AnyCodable]> {
12041204
return try await updateStatus(
12051205
nestedType: [String: AnyCodable].self
12061206
)

Sources/Appwrite/Services/Databases.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,25 @@ open class Databases: Service {
168168
/// @param String databaseId
169169
/// @param String collectionId
170170
/// @param String documentId
171+
/// @param [String] queries
171172
/// @throws Exception
172173
/// @return array
173174
///
174175
open func getDocument<T>(
175176
databaseId: String,
176177
collectionId: String,
177178
documentId: String,
179+
queries: [String]? = nil,
178180
nestedType: T.Type
179181
) async throws -> AppwriteModels.Document<T> {
180182
let path: String = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
181183
.replacingOccurrences(of: "{databaseId}", with: databaseId)
182184
.replacingOccurrences(of: "{collectionId}", with: collectionId)
183185
.replacingOccurrences(of: "{documentId}", with: documentId)
184186

185-
let params: [String: Any] = [:]
187+
let params: [String: Any?] = [
188+
"queries": queries
189+
]
186190

187191
let headers: [String: String] = [
188192
"content-type": "application/json"
@@ -210,18 +214,21 @@ open class Databases: Service {
210214
/// @param String databaseId
211215
/// @param String collectionId
212216
/// @param String documentId
217+
/// @param [String] queries
213218
/// @throws Exception
214219
/// @return array
215220
///
216221
open func getDocument(
217222
databaseId: String,
218223
collectionId: String,
219-
documentId: String
224+
documentId: String,
225+
queries: [String]? = nil
220226
) async throws -> AppwriteModels.Document<[String: AnyCodable]> {
221227
return try await getDocument(
222228
databaseId: databaseId,
223229
collectionId: collectionId,
224230
documentId: documentId,
231+
queries: queries,
225232
nestedType: [String: AnyCodable].self
226233
)
227234
}

0 commit comments

Comments
 (0)