Skip to content

Commit f62348c

Browse files
committed
Add new push message parameters
1 parent a03ac79 commit f62348c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+225
-194
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.6.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.6.1-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: "[email protected]:appwrite/sdk-for-swift.git", from: "6.1.0"),
36+
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "6.2.0"),
3737
],
3838
```
3939

Sources/Appwrite/Client.swift

Lines changed: 8 additions & 8 deletions
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": "6.1.0",
24+
"x-sdk-version": "6.2.0",
2525
"x-appwrite-response-format": "1.6.0"
2626
]
2727

@@ -530,23 +530,23 @@ open class Client {
530530
if param is String
531531
|| param is Int
532532
|| param is Float
533+
|| param is Double
533534
|| param is Bool
534535
|| param is [String]
535536
|| param is [Int]
536537
|| param is [Float]
538+
|| param is [Double]
537539
|| param is [Bool]
538540
|| param is [String: Any]
539541
|| param is [Int: Any]
540542
|| param is [Float: Any]
543+
|| param is [Double: Any]
541544
|| param is [Bool: Any] {
542545
encodedParams[key] = param
543-
} else {
544-
let value = try! (param as! Encodable).toJson()
545-
546-
let range = value.index(value.startIndex, offsetBy: 1)..<value.index(value.endIndex, offsetBy: -1)
547-
let substring = value[range]
548-
549-
encodedParams[key] = substring
546+
} else if let encodable = param as? Encodable {
547+
encodedParams[key] = try encodable.toJson()
548+
} else if let param = param {
549+
encodedParams[key] = String(describing: param)
550550
}
551551
}
552552

Sources/Appwrite/Services/Account.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,9 +1596,7 @@ open class Account: Service {
15961596
/// [POST
15971597
/// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
15981598
/// endpoint to complete the login process. The link sent to the user's email
1599-
/// address is valid for 1 hour. If you are on a mobile device you can leave
1600-
/// the URL parameter empty, so that the login completion will be handled by
1601-
/// your Appwrite instance by default.
1599+
/// address is valid for 1 hour.
16021600
///
16031601
/// A user is limited to 10 active sessions at a time by default. [Learn more
16041602
/// about session

Sources/Appwrite/Services/Functions.swift

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ open class Functions: Service {
720720
/// function execution process will start asynchronously.
721721
///
722722
/// @param String functionId
723-
/// @param payload body
723+
/// @param String body
724724
/// @param Bool async
725725
/// @param String path
726726
/// @param AppwriteEnums.ExecutionMethod method
@@ -731,18 +731,17 @@ open class Functions: Service {
731731
///
732732
open func createExecution(
733733
functionId: String,
734-
body: payload? = nil,
734+
body: String? = nil,
735735
async: Bool? = nil,
736736
path: String? = nil,
737737
method: AppwriteEnums.ExecutionMethod? = nil,
738738
headers: Any? = nil,
739-
scheduledAt: String? = nil,
740-
onProgress: ((UploadProgress) -> Void)? = nil
739+
scheduledAt: String? = nil
741740
) async throws -> AppwriteModels.Execution {
742741
let apiPath: String = "/functions/{functionId}/executions"
743742
.replacingOccurrences(of: "{functionId}", with: functionId)
744743

745-
var apiParams: [String: Any?] = [
744+
let apiParams: [String: Any?] = [
746745
"body": body,
747746
"async": async,
748747
"path": path,
@@ -751,23 +750,20 @@ open class Functions: Service {
751750
"scheduledAt": scheduledAt
752751
]
753752

754-
var apiHeaders: [String: String] = [
755-
"content-type": "multipart/form-data"
753+
let apiHeaders: [String: String] = [
754+
"content-type": "application/json"
756755
]
757756

758757
let converter: (Any) -> AppwriteModels.Execution = { response in
759758
return AppwriteModels.Execution.from(map: response as! [String: Any])
760759
}
761760

762-
let idParamName: String? = nil
763-
return try await client.chunkedUpload(
761+
return try await client.call(
762+
method: "POST",
764763
path: apiPath,
765-
headers: &apiHeaders,
766-
params: &apiParams,
767-
paramName: paramName,
768-
idParamName: idParamName,
769-
converter: converter,
770-
onProgress: onProgress
764+
headers: apiHeaders,
765+
params: apiParams,
766+
converter: converter
771767
)
772768
}
773769

Sources/Appwrite/Services/Messaging.swift

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,19 @@ open class Messaging: Service {
201201
/// @param String sound
202202
/// @param String color
203203
/// @param String tag
204-
/// @param String badge
204+
/// @param Int badge
205205
/// @param Bool draft
206206
/// @param String scheduledAt
207+
/// @param Bool contentAvailable
208+
/// @param Bool critical
209+
/// @param AppwriteEnums.MessagePriority priority
207210
/// @throws Exception
208211
/// @return array
209212
///
210213
open func createPush(
211214
messageId: String,
212-
title: String,
213-
body: String,
215+
title: String? = nil,
216+
body: String? = nil,
214217
topics: [String]? = nil,
215218
users: [String]? = nil,
216219
targets: [String]? = nil,
@@ -221,9 +224,12 @@ open class Messaging: Service {
221224
sound: String? = nil,
222225
color: String? = nil,
223226
tag: String? = nil,
224-
badge: String? = nil,
227+
badge: Int? = nil,
225228
draft: Bool? = nil,
226-
scheduledAt: String? = nil
229+
scheduledAt: String? = nil,
230+
contentAvailable: Bool? = nil,
231+
critical: Bool? = nil,
232+
priority: AppwriteEnums.MessagePriority? = nil
227233
) async throws -> AppwriteModels.Message {
228234
let apiPath: String = "/messaging/messages/push"
229235

@@ -243,7 +249,10 @@ open class Messaging: Service {
243249
"tag": tag,
244250
"badge": badge,
245251
"draft": draft,
246-
"scheduledAt": scheduledAt
252+
"scheduledAt": scheduledAt,
253+
"contentAvailable": contentAvailable,
254+
"critical": critical,
255+
"priority": priority
247256
]
248257

249258
let apiHeaders: [String: String] = [
@@ -285,6 +294,9 @@ open class Messaging: Service {
285294
/// @param Int badge
286295
/// @param Bool draft
287296
/// @param String scheduledAt
297+
/// @param Bool contentAvailable
298+
/// @param Bool critical
299+
/// @param AppwriteEnums.MessagePriority priority
288300
/// @throws Exception
289301
/// @return array
290302
///
@@ -304,7 +316,10 @@ open class Messaging: Service {
304316
tag: String? = nil,
305317
badge: Int? = nil,
306318
draft: Bool? = nil,
307-
scheduledAt: String? = nil
319+
scheduledAt: String? = nil,
320+
contentAvailable: Bool? = nil,
321+
critical: Bool? = nil,
322+
priority: AppwriteEnums.MessagePriority? = nil
308323
) async throws -> AppwriteModels.Message {
309324
let apiPath: String = "/messaging/messages/push/{messageId}"
310325
.replacingOccurrences(of: "{messageId}", with: messageId)
@@ -324,7 +339,10 @@ open class Messaging: Service {
324339
"tag": tag,
325340
"badge": badge,
326341
"draft": draft,
327-
"scheduledAt": scheduledAt
342+
"scheduledAt": scheduledAt,
343+
"contentAvailable": contentAvailable,
344+
"critical": critical,
345+
"priority": priority
328346
]
329347

330348
let apiHeaders: [String: String] = [

Sources/Appwrite/Services/Teams.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ open class Teams: Service {
286286
/// List team memberships
287287
///
288288
/// Use this endpoint to list a team's members using the team's ID. All team
289-
/// members have read access to this endpoint.
289+
/// members have read access to this endpoint. Hide sensitive attributes from
290+
/// the response by toggling membership privacy in the Console.
290291
///
291292
/// @param String teamId
292293
/// @param [String] queries
@@ -401,7 +402,8 @@ open class Teams: Service {
401402
/// Get team membership
402403
///
403404
/// Get a team member by the membership unique id. All team members have read
404-
/// access for this resource.
405+
/// access for this resource. Hide sensitive attributes from the response by
406+
/// toggling membership privacy in the Console.
405407
///
406408
/// @param String teamId
407409
/// @param String membershipId
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import Foundation
22

3-
public enum AuthenticationFactor: String, Codable {
3+
public enum AuthenticationFactor: String, CustomStringConvertible {
44
case email = "email"
55
case phone = "phone"
66
case totp = "totp"
77
case recoverycode = "recoverycode"
88

9-
public func encode(to encoder: Encoder) throws {
10-
var container = encoder.singleValueContainer()
11-
try container.encode(rawValue)
9+
public var description: String {
10+
return rawValue
1211
}
1312
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import Foundation
22

3-
public enum AuthenticatorType: String, Codable {
3+
public enum AuthenticatorType: String, CustomStringConvertible {
44
case totp = "totp"
55

6-
public func encode(to encoder: Encoder) throws {
7-
var container = encoder.singleValueContainer()
8-
try container.encode(rawValue)
6+
public var description: String {
7+
return rawValue
98
}
109
}

Sources/AppwriteEnums/Browser.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public enum Browser: String, Codable {
3+
public enum Browser: String, CustomStringConvertible {
44
case avantBrowser = "aa"
55
case androidWebViewBeta = "an"
66
case googleChrome = "ch"
@@ -16,8 +16,7 @@ public enum Browser: String, Codable {
1616
case opera = "op"
1717
case operaNext = "on"
1818

19-
public func encode(to encoder: Encoder) throws {
20-
var container = encoder.singleValueContainer()
21-
try container.encode(rawValue)
19+
public var description: String {
20+
return rawValue
2221
}
2322
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import Foundation
22

3-
public enum Compression: String, Codable {
3+
public enum Compression: String, CustomStringConvertible {
44
case `none` = "none"
55
case gzip = "gzip"
66
case zstd = "zstd"
77

8-
public func encode(to encoder: Encoder) throws {
9-
var container = encoder.singleValueContainer()
10-
try container.encode(rawValue)
8+
public var description: String {
9+
return rawValue
1110
}
1211
}

Sources/AppwriteEnums/CreditCard.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public enum CreditCard: String, Codable {
3+
public enum CreditCard: String, CustomStringConvertible {
44
case americanExpress = "amex"
55
case argencard = "argencard"
66
case cabal = "cabal"
@@ -18,8 +18,7 @@ public enum CreditCard: String, Codable {
1818
case mIR = "mir"
1919
case maestro = "maestro"
2020

21-
public func encode(to encoder: Encoder) throws {
22-
var container = encoder.singleValueContainer()
23-
try container.encode(rawValue)
21+
public var description: String {
22+
return rawValue
2423
}
2524
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import Foundation
22

3-
public enum ExecutionMethod: String, Codable {
3+
public enum ExecutionMethod: String, CustomStringConvertible {
44
case gET = "GET"
55
case pOST = "POST"
66
case pUT = "PUT"
77
case pATCH = "PATCH"
88
case dELETE = "DELETE"
99
case oPTIONS = "OPTIONS"
1010

11-
public func encode(to encoder: Encoder) throws {
12-
var container = encoder.singleValueContainer()
13-
try container.encode(rawValue)
11+
public var description: String {
12+
return rawValue
1413
}
1514
}

Sources/AppwriteEnums/Flag.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public enum Flag: String, Codable {
3+
public enum Flag: String, CustomStringConvertible {
44
case afghanistan = "af"
55
case angola = "ao"
66
case albania = "al"
@@ -197,8 +197,7 @@ public enum Flag: String, Codable {
197197
case zambia = "zm"
198198
case zimbabwe = "zw"
199199

200-
public func encode(to encoder: Encoder) throws {
201-
var container = encoder.singleValueContainer()
202-
try container.encode(rawValue)
200+
public var description: String {
201+
return rawValue
203202
}
204203
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import Foundation
22

3-
public enum ImageFormat: String, Codable {
3+
public enum ImageFormat: String, CustomStringConvertible {
44
case jpg = "jpg"
55
case jpeg = "jpeg"
66
case gif = "gif"
77
case png = "png"
88
case webp = "webp"
99
case avif = "avif"
1010

11-
public func encode(to encoder: Encoder) throws {
12-
var container = encoder.singleValueContainer()
13-
try container.encode(rawValue)
11+
public var description: String {
12+
return rawValue
1413
}
1514
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public enum ImageGravity: String, Codable {
3+
public enum ImageGravity: String, CustomStringConvertible {
44
case center = "center"
55
case topLeft = "top-left"
66
case top = "top"
@@ -11,8 +11,7 @@ public enum ImageGravity: String, Codable {
1111
case bottom = "bottom"
1212
case bottomRight = "bottom-right"
1313

14-
public func encode(to encoder: Encoder) throws {
15-
var container = encoder.singleValueContainer()
16-
try container.encode(rawValue)
14+
public var description: String {
15+
return rawValue
1716
}
1817
}

0 commit comments

Comments
 (0)