Skip to content

Commit 362d8b3

Browse files
Merge pull request #71 from appwrite/dev
fix: remove content-type from GET requests
2 parents 2f7e41e + d1fc389 commit 362d8b3

File tree

10 files changed

+45
-91
lines changed

10 files changed

+45
-91
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-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.6.1-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.6.2-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)
@@ -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: "9.0.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "9.0.1"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 12 additions & 8 deletions
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": "9.0.0",
26+
"x-sdk-version": "9.0.1",
2727
"x-appwrite-response-format": "1.6.0"
2828
]
2929

@@ -170,14 +170,15 @@ open class Client {
170170
/// @return Client
171171
///
172172
open func setEndpoint(_ endPoint: String) -> Client {
173-
self.endPoint = endPoint
174-
175-
if (self.endPointRealtime == nil && endPoint.starts(with: "http")) {
176-
self.endPointRealtime = endPoint
177-
.replacingOccurrences(of: "http://", with: "ws://")
178-
.replacingOccurrences(of: "https://", with: "wss://")
173+
if !endPoint.hasPrefix("http://") && !endPoint.hasPrefix("https://") {
174+
fatalError("Invalid endpoint URL: \(endPoint)")
179175
}
180176

177+
self.endPoint = endPoint
178+
self.endPointRealtime = endPoint
179+
.replacingOccurrences(of: "http://", with: "ws://")
180+
.replacingOccurrences(of: "https://", with: "wss://")
181+
181182
return self
182183
}
183184

@@ -189,8 +190,11 @@ open class Client {
189190
/// @return Client
190191
///
191192
open func setEndpointRealtime(_ endPoint: String) -> Client {
192-
self.endPointRealtime = endPoint
193+
if !endPoint.hasPrefix("ws://") && !endPoint.hasPrefix("wss://") {
194+
fatalError("Invalid realtime endpoint URL: \(endPoint)")
195+
}
193196

197+
self.endPointRealtime = endPoint
194198
return self
195199
}
196200

Sources/Appwrite/Services/Account.swift

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ open class Account: Service {
2121

2222
let apiParams: [String: Any] = [:]
2323

24-
let apiHeaders: [String: String] = [
25-
"content-type": "application/json"
26-
]
24+
let apiHeaders: [String: String] = [:]
2725

2826
let converter: (Any) -> AppwriteModels.User<T> = { response in
2927
return AppwriteModels.User.from(map: response as! [String: Any])
@@ -217,9 +215,7 @@ open class Account: Service {
217215
"queries": queries
218216
]
219217

220-
let apiHeaders: [String: String] = [
221-
"content-type": "application/json"
222-
]
218+
let apiHeaders: [String: String] = [:]
223219

224220
let converter: (Any) -> AppwriteModels.IdentityList = { response in
225221
return AppwriteModels.IdentityList.from(map: response as! [String: Any])
@@ -310,9 +306,7 @@ open class Account: Service {
310306
"queries": queries
311307
]
312308

313-
let apiHeaders: [String: String] = [
314-
"content-type": "application/json"
315-
]
309+
let apiHeaders: [String: String] = [:]
316310

317311
let converter: (Any) -> AppwriteModels.LogList = { response in
318312
return AppwriteModels.LogList.from(map: response as! [String: Any])
@@ -585,9 +579,7 @@ open class Account: Service {
585579

586580
let apiParams: [String: Any] = [:]
587581

588-
let apiHeaders: [String: String] = [
589-
"content-type": "application/json"
590-
]
582+
let apiHeaders: [String: String] = [:]
591583

592584
let converter: (Any) -> AppwriteModels.MfaFactors = { response in
593585
return AppwriteModels.MfaFactors.from(map: response as! [String: Any])
@@ -617,9 +609,7 @@ open class Account: Service {
617609

618610
let apiParams: [String: Any] = [:]
619611

620-
let apiHeaders: [String: String] = [
621-
"content-type": "application/json"
622-
]
612+
let apiHeaders: [String: String] = [:]
623613

624614
let converter: (Any) -> AppwriteModels.MfaRecoveryCodes = { response in
625615
return AppwriteModels.MfaRecoveryCodes.from(map: response as! [String: Any])
@@ -886,9 +876,7 @@ open class Account: Service {
886876

887877
let apiParams: [String: Any] = [:]
888878

889-
let apiHeaders: [String: String] = [
890-
"content-type": "application/json"
891-
]
879+
let apiHeaders: [String: String] = [:]
892880

893881
let converter: (Any) -> AppwriteModels.Preferences<T> = { response in
894882
return AppwriteModels.Preferences.from(map: response as! [String: Any])
@@ -1074,9 +1062,7 @@ open class Account: Service {
10741062

10751063
let apiParams: [String: Any] = [:]
10761064

1077-
let apiHeaders: [String: String] = [
1078-
"content-type": "application/json"
1079-
]
1065+
let apiHeaders: [String: String] = [:]
10801066

10811067
let converter: (Any) -> AppwriteModels.SessionList = { response in
10821068
return AppwriteModels.SessionList.from(map: response as! [String: Any])
@@ -1380,9 +1366,7 @@ open class Account: Service {
13801366

13811367
let apiParams: [String: Any] = [:]
13821368

1383-
let apiHeaders: [String: String] = [
1384-
"content-type": "application/json"
1385-
]
1369+
let apiHeaders: [String: String] = [:]
13861370

13871371
let converter: (Any) -> AppwriteModels.Session = { response in
13881372
return AppwriteModels.Session.from(map: response as! [String: Any])

Sources/Appwrite/Services/Databases.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ open class Databases: Service {
3232
"queries": queries
3333
]
3434

35-
let apiHeaders: [String: String] = [
36-
"content-type": "application/json"
37-
]
35+
let apiHeaders: [String: String] = [:]
3836

3937
let converter: (Any) -> AppwriteModels.DocumentList<T> = { response in
4038
return AppwriteModels.DocumentList.from(map: response as! [String: Any])
@@ -77,6 +75,7 @@ open class Databases: Service {
7775
/// collection resource using either a [server
7876
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
7977
/// API or directly from your database console.
78+
///
8079
///
8180
/// @param String databaseId
8281
/// @param String collectionId
@@ -126,6 +125,7 @@ open class Databases: Service {
126125
/// collection resource using either a [server
127126
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
128127
/// API or directly from your database console.
128+
///
129129
///
130130
/// @param String databaseId
131131
/// @param String collectionId
@@ -179,9 +179,7 @@ open class Databases: Service {
179179
"queries": queries
180180
]
181181

182-
let apiHeaders: [String: String] = [
183-
"content-type": "application/json"
184-
]
182+
let apiHeaders: [String: String] = [:]
185183

186184
let converter: (Any) -> AppwriteModels.Document<T> = { response in
187185
return AppwriteModels.Document.from(map: response as! [String: Any])

Sources/Appwrite/Services/Functions.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ open class Functions: Service {
3131
"search": search
3232
]
3333

34-
let apiHeaders: [String: String] = [
35-
"content-type": "application/json"
36-
]
34+
let apiHeaders: [String: String] = [:]
3735

3836
let converter: (Any) -> AppwriteModels.ExecutionList = { response in
3937
return AppwriteModels.ExecutionList.from(map: response as! [String: Any])
@@ -120,9 +118,7 @@ open class Functions: Service {
120118

121119
let apiParams: [String: Any] = [:]
122120

123-
let apiHeaders: [String: String] = [
124-
"content-type": "application/json"
125-
]
121+
let apiHeaders: [String: String] = [:]
126122

127123
let converter: (Any) -> AppwriteModels.Execution = { response in
128124
return AppwriteModels.Execution.from(map: response as! [String: Any])

Sources/Appwrite/Services/Locale.swift

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ open class Locale: Service {
2525

2626
let apiParams: [String: Any] = [:]
2727

28-
let apiHeaders: [String: String] = [
29-
"content-type": "application/json"
30-
]
28+
let apiHeaders: [String: String] = [:]
3129

3230
let converter: (Any) -> AppwriteModels.Locale = { response in
3331
return AppwriteModels.Locale.from(map: response as! [String: Any])
@@ -55,9 +53,7 @@ open class Locale: Service {
5553

5654
let apiParams: [String: Any] = [:]
5755

58-
let apiHeaders: [String: String] = [
59-
"content-type": "application/json"
60-
]
56+
let apiHeaders: [String: String] = [:]
6157

6258
let converter: (Any) -> AppwriteModels.LocaleCodeList = { response in
6359
return AppwriteModels.LocaleCodeList.from(map: response as! [String: Any])
@@ -85,9 +81,7 @@ open class Locale: Service {
8581

8682
let apiParams: [String: Any] = [:]
8783

88-
let apiHeaders: [String: String] = [
89-
"content-type": "application/json"
90-
]
84+
let apiHeaders: [String: String] = [:]
9185

9286
let converter: (Any) -> AppwriteModels.ContinentList = { response in
9387
return AppwriteModels.ContinentList.from(map: response as! [String: Any])
@@ -115,9 +109,7 @@ open class Locale: Service {
115109

116110
let apiParams: [String: Any] = [:]
117111

118-
let apiHeaders: [String: String] = [
119-
"content-type": "application/json"
120-
]
112+
let apiHeaders: [String: String] = [:]
121113

122114
let converter: (Any) -> AppwriteModels.CountryList = { response in
123115
return AppwriteModels.CountryList.from(map: response as! [String: Any])
@@ -145,9 +137,7 @@ open class Locale: Service {
145137

146138
let apiParams: [String: Any] = [:]
147139

148-
let apiHeaders: [String: String] = [
149-
"content-type": "application/json"
150-
]
140+
let apiHeaders: [String: String] = [:]
151141

152142
let converter: (Any) -> AppwriteModels.CountryList = { response in
153143
return AppwriteModels.CountryList.from(map: response as! [String: Any])
@@ -175,9 +165,7 @@ open class Locale: Service {
175165

176166
let apiParams: [String: Any] = [:]
177167

178-
let apiHeaders: [String: String] = [
179-
"content-type": "application/json"
180-
]
168+
let apiHeaders: [String: String] = [:]
181169

182170
let converter: (Any) -> AppwriteModels.PhoneList = { response in
183171
return AppwriteModels.PhoneList.from(map: response as! [String: Any])
@@ -206,9 +194,7 @@ open class Locale: Service {
206194

207195
let apiParams: [String: Any] = [:]
208196

209-
let apiHeaders: [String: String] = [
210-
"content-type": "application/json"
211-
]
197+
let apiHeaders: [String: String] = [:]
212198

213199
let converter: (Any) -> AppwriteModels.CurrencyList = { response in
214200
return AppwriteModels.CurrencyList.from(map: response as! [String: Any])
@@ -236,9 +222,7 @@ open class Locale: Service {
236222

237223
let apiParams: [String: Any] = [:]
238224

239-
let apiHeaders: [String: String] = [
240-
"content-type": "application/json"
241-
]
225+
let apiHeaders: [String: String] = [:]
242226

243227
let converter: (Any) -> AppwriteModels.LanguageList = { response in
244228
return AppwriteModels.LanguageList.from(map: response as! [String: Any])

Sources/Appwrite/Services/Storage.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ open class Storage: Service {
3131
"search": search
3232
]
3333

34-
let apiHeaders: [String: String] = [
35-
"content-type": "application/json"
36-
]
34+
let apiHeaders: [String: String] = [:]
3735

3836
let converter: (Any) -> AppwriteModels.FileList = { response in
3937
return AppwriteModels.FileList.from(map: response as! [String: Any])
@@ -131,9 +129,7 @@ open class Storage: Service {
131129

132130
let apiParams: [String: Any] = [:]
133131

134-
let apiHeaders: [String: String] = [
135-
"content-type": "application/json"
136-
]
132+
let apiHeaders: [String: String] = [:]
137133

138134
let converter: (Any) -> AppwriteModels.File = { response in
139135
return AppwriteModels.File.from(map: response as! [String: Any])

Sources/Appwrite/Services/Teams.swift

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ open class Teams: Service {
2929
"search": search
3030
]
3131

32-
let apiHeaders: [String: String] = [
33-
"content-type": "application/json"
34-
]
32+
let apiHeaders: [String: String] = [:]
3533

3634
let converter: (Any) -> AppwriteModels.TeamList<T> = { response in
3735
return AppwriteModels.TeamList.from(map: response as! [String: Any])
@@ -148,9 +146,7 @@ open class Teams: Service {
148146

149147
let apiParams: [String: Any] = [:]
150148

151-
let apiHeaders: [String: String] = [
152-
"content-type": "application/json"
153-
]
149+
let apiHeaders: [String: String] = [:]
154150

155151
let converter: (Any) -> AppwriteModels.Team<T> = { response in
156152
return AppwriteModels.Team.from(map: response as! [String: Any])
@@ -288,9 +284,7 @@ open class Teams: Service {
288284
"search": search
289285
]
290286

291-
let apiHeaders: [String: String] = [
292-
"content-type": "application/json"
293-
]
287+
let apiHeaders: [String: String] = [:]
294288

295289
let converter: (Any) -> AppwriteModels.MembershipList = { response in
296290
return AppwriteModels.MembershipList.from(map: response as! [String: Any])
@@ -396,9 +390,7 @@ open class Teams: Service {
396390

397391
let apiParams: [String: Any] = [:]
398392

399-
let apiHeaders: [String: String] = [
400-
"content-type": "application/json"
401-
]
393+
let apiHeaders: [String: String] = [:]
402394

403395
let converter: (Any) -> AppwriteModels.Membership = { response in
404396
return AppwriteModels.Membership.from(map: response as! [String: Any])
@@ -552,9 +544,7 @@ open class Teams: Service {
552544

553545
let apiParams: [String: Any] = [:]
554546

555-
let apiHeaders: [String: String] = [
556-
"content-type": "application/json"
557-
]
547+
let apiHeaders: [String: String] = [:]
558548

559549
let converter: (Any) -> AppwriteModels.Preferences<T> = { response in
560550
return AppwriteModels.Preferences.from(map: response as! [String: Any])

Sources/AppwriteEnums/CreditCard.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum CreditCard: String, CustomStringConvertible {
1717
case visa = "visa"
1818
case mIR = "mir"
1919
case maestro = "maestro"
20+
case rupay = "rupay"
2021

2122
public var description: String {
2223
return rawValue

Sources/AppwriteEnums/OAuthProvider.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum OAuthProvider: String, CustomStringConvertible {
1515
case dropbox = "dropbox"
1616
case etsy = "etsy"
1717
case facebook = "facebook"
18+
case figma = "figma"
1819
case github = "github"
1920
case gitlab = "gitlab"
2021
case google = "google"

0 commit comments

Comments
 (0)