Skip to content

Commit 907ac8a

Browse files
authored
Merge pull request #88 from appwrite/dev
feat: Apple SDK update for version 13.1.0
2 parents 8f79e67 + baf0d22 commit 907ac8a

File tree

7 files changed

+130
-10
lines changed

7 files changed

+130
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 13.1.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 10.2.0
49

510
* Update sdk to use swift-native doc comments instead of jsdoc styled comments as per [Swift Documentation Comments](https://github.com/swiftlang/swift/blob/main/docs/DocumentationComments.md)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: "13.0.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "13.1.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": "13.0.0",
26+
"x-sdk-version": "13.1.0",
2727
"x-appwrite-response-format": "1.8.0"
2828
]
2929

Sources/Appwrite/Services/Account.swift

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,10 +2210,59 @@ open class Account: Service {
22102210
/// - Throws: Exception if the request fails
22112211
/// - Returns: AppwriteModels.Token
22122212
///
2213+
open func createEmailVerification(
2214+
url: String
2215+
) async throws -> AppwriteModels.Token {
2216+
let apiPath: String = "/account/verifications/email"
2217+
2218+
let apiParams: [String: Any?] = [
2219+
"url": url
2220+
]
2221+
2222+
let apiHeaders: [String: String] = [
2223+
"content-type": "application/json"
2224+
]
2225+
2226+
let converter: (Any) -> AppwriteModels.Token = { response in
2227+
return AppwriteModels.Token.from(map: response as! [String: Any])
2228+
}
2229+
2230+
return try await client.call(
2231+
method: "POST",
2232+
path: apiPath,
2233+
headers: apiHeaders,
2234+
params: apiParams,
2235+
converter: converter
2236+
)
2237+
}
2238+
2239+
///
2240+
/// Use this endpoint to send a verification message to your user email address
2241+
/// to confirm they are the valid owners of that address. Both the **userId**
2242+
/// and **secret** arguments will be passed as query parameters to the URL you
2243+
/// have provided to be attached to the verification email. The provided URL
2244+
/// should redirect the user back to your app and allow you to complete the
2245+
/// verification process by verifying both the **userId** and **secret**
2246+
/// parameters. Learn more about how to [complete the verification
2247+
/// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
2248+
/// The verification link sent to the user's email address is valid for 7 days.
2249+
///
2250+
/// Please note that in order to avoid a [Redirect
2251+
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
2252+
/// the only valid redirect URLs are the ones from domains you have set when
2253+
/// adding your platforms in the console interface.
2254+
///
2255+
///
2256+
/// - Parameters:
2257+
/// - url: String
2258+
/// - Throws: Exception if the request fails
2259+
/// - Returns: AppwriteModels.Token
2260+
///
2261+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.")
22132262
open func createVerification(
22142263
url: String
22152264
) async throws -> AppwriteModels.Token {
2216-
let apiPath: String = "/account/verification"
2265+
let apiPath: String = "/account/verifications/email"
22172266

22182267
let apiParams: [String: Any?] = [
22192268
"url": url
@@ -2248,11 +2297,52 @@ open class Account: Service {
22482297
/// - Throws: Exception if the request fails
22492298
/// - Returns: AppwriteModels.Token
22502299
///
2300+
open func updateEmailVerification(
2301+
userId: String,
2302+
secret: String
2303+
) async throws -> AppwriteModels.Token {
2304+
let apiPath: String = "/account/verifications/email"
2305+
2306+
let apiParams: [String: Any?] = [
2307+
"userId": userId,
2308+
"secret": secret
2309+
]
2310+
2311+
let apiHeaders: [String: String] = [
2312+
"content-type": "application/json"
2313+
]
2314+
2315+
let converter: (Any) -> AppwriteModels.Token = { response in
2316+
return AppwriteModels.Token.from(map: response as! [String: Any])
2317+
}
2318+
2319+
return try await client.call(
2320+
method: "PUT",
2321+
path: apiPath,
2322+
headers: apiHeaders,
2323+
params: apiParams,
2324+
converter: converter
2325+
)
2326+
}
2327+
2328+
///
2329+
/// Use this endpoint to complete the user email verification process. Use both
2330+
/// the **userId** and **secret** parameters that were attached to your app URL
2331+
/// to verify the user email ownership. If confirmed this route will return a
2332+
/// 200 status code.
2333+
///
2334+
/// - Parameters:
2335+
/// - userId: String
2336+
/// - secret: String
2337+
/// - Throws: Exception if the request fails
2338+
/// - Returns: AppwriteModels.Token
2339+
///
2340+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.")
22512341
open func updateVerification(
22522342
userId: String,
22532343
secret: String
22542344
) async throws -> AppwriteModels.Token {
2255-
let apiPath: String = "/account/verification"
2345+
let apiPath: String = "/account/verifications/email"
22562346

22572347
let apiParams: [String: Any?] = [
22582348
"userId": userId,
@@ -2291,7 +2381,7 @@ open class Account: Service {
22912381
///
22922382
open func createPhoneVerification(
22932383
) async throws -> AppwriteModels.Token {
2294-
let apiPath: String = "/account/verification/phone"
2384+
let apiPath: String = "/account/verifications/phone"
22952385

22962386
let apiParams: [String: Any] = [:]
22972387

@@ -2328,7 +2418,7 @@ open class Account: Service {
23282418
userId: String,
23292419
secret: String
23302420
) async throws -> AppwriteModels.Token {
2331-
let apiPath: String = "/account/verification/phone"
2421+
let apiPath: String = "/account/verifications/phone"
23322422

23332423
let apiParams: [String: Any?] = [
23342424
"userId": userId,

Sources/Appwrite/Services/TablesDb.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ open class TablesDB: Service {
7575
///
7676
/// Create a new Row. Before using this route, you should create a new table
7777
/// resource using either a [server
78-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
78+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
7979
/// API or directly from your database console.
8080
///
8181
/// - Parameters:
@@ -125,7 +125,7 @@ open class TablesDB: Service {
125125
///
126126
/// Create a new Row. Before using this route, you should create a new table
127127
/// resource using either a [server
128-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
128+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
129129
/// API or directly from your database console.
130130
///
131131
/// - Parameters:
@@ -227,7 +227,7 @@ open class TablesDB: Service {
227227
///
228228
/// Create or update a Row. Before using this route, you should create a new
229229
/// table resource using either a [server
230-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
230+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
231231
/// API or directly from your database console.
232232
///
233233
/// - Parameters:
@@ -277,7 +277,7 @@ open class TablesDB: Service {
277277
///
278278
/// Create or update a Row. Before using this route, you should create a new
279279
/// table resource using either a [server
280-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
280+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
281281
/// API or directly from your database console.
282282
///
283283
/// - Parameters:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Appwrite
2+
3+
let client = Client()
4+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
5+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
6+
7+
let account = Account(client)
8+
9+
let token = try await account.createEmailVerification(
10+
url: "https://example.com"
11+
)
12+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Appwrite
2+
3+
let client = Client()
4+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
5+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
6+
7+
let account = Account(client)
8+
9+
let token = try await account.updateEmailVerification(
10+
userId: "<USER_ID>",
11+
secret: "<SECRET>"
12+
)
13+

0 commit comments

Comments
 (0)