Skip to content

fix: remove content-type from GET requests #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down Expand Up @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "8.0.0"),
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "9.0.0"),
],
```

Expand Down
7 changes: 5 additions & 2 deletions Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class Client {
"x-sdk-name": "Swift",
"x-sdk-platform": "server",
"x-sdk-language": "swift",
"x-sdk-version": "8.0.0",
"x-sdk-version": "9.0.0",
"x-appwrite-response-format": "1.6.0"
]

Expand Down Expand Up @@ -197,8 +197,11 @@ open class Client {
/// @return Client
///
open func setEndpoint(_ endPoint: String) -> Client {
self.endPoint = endPoint
if !endPoint.hasPrefix("http://") && !endPoint.hasPrefix("https://") {
fatalError("Invalid endpoint URL: \(endPoint)")
}

self.endPoint = endPoint
return self
}

Expand Down
36 changes: 9 additions & 27 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ open class Account: Service {

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

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

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

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

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

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

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

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

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.SessionList = { response in
return AppwriteModels.SessionList.from(map: response as! [String: Any])
Expand Down Expand Up @@ -1321,9 +1307,7 @@ open class Account: Service {

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.Session = { response in
return AppwriteModels.Session.from(map: response as! [String: Any])
Expand Down Expand Up @@ -1591,9 +1575,7 @@ open class Account: Service {
"project": client.config["project"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.redirect(
method: "GET",
Expand Down
28 changes: 7 additions & 21 deletions Sources/Appwrite/Services/Avatars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -90,9 +88,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -122,9 +118,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -169,9 +163,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -214,9 +206,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -267,9 +257,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -307,9 +295,7 @@ open class Avatars: Service {
"session": client.config["session"]
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down
54 changes: 18 additions & 36 deletions Sources/Appwrite/Services/Databases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ open class Databases: Service {
"search": search
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.DatabaseList = { response in
return AppwriteModels.DatabaseList.from(map: response as! [String: Any])
Expand Down Expand Up @@ -101,9 +99,7 @@ open class Databases: Service {

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.Database = { response in
return AppwriteModels.Database.from(map: response as! [String: Any])
Expand Down Expand Up @@ -207,9 +203,7 @@ open class Databases: Service {
"search": search
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.CollectionList = { response in
return AppwriteModels.CollectionList.from(map: response as! [String: Any])
Expand Down Expand Up @@ -294,9 +288,7 @@ open class Databases: Service {

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.Collection = { response in
return AppwriteModels.Collection.from(map: response as! [String: Any])
Expand Down Expand Up @@ -411,9 +403,7 @@ open class Databases: Service {
"queries": queries
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.AttributeList = { response in
return AppwriteModels.AttributeList.from(map: response as! [String: Any])
Expand Down Expand Up @@ -893,9 +883,9 @@ open class Databases: Service {
/// @param String collectionId
/// @param String key
/// @param Bool required
/// @param Double default
/// @param Double min
/// @param Double max
/// @param Double default
/// @param String newKey
/// @throws Exception
/// @return array
Expand All @@ -905,9 +895,9 @@ open class Databases: Service {
collectionId: String,
key: String,
`required`: Bool,
min: Double,
max: Double,
`default`: Double? = nil,
min: Double? = nil,
max: Double? = nil,
newKey: String? = nil
) async throws -> AppwriteModels.AttributeFloat {
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}"
Expand Down Expand Up @@ -1005,9 +995,9 @@ open class Databases: Service {
/// @param String collectionId
/// @param String key
/// @param Bool required
/// @param Int default
/// @param Int min
/// @param Int max
/// @param Int default
/// @param String newKey
/// @throws Exception
/// @return array
Expand All @@ -1017,9 +1007,9 @@ open class Databases: Service {
collectionId: String,
key: String,
`required`: Bool,
min: Int,
max: Int,
`default`: Int? = nil,
min: Int? = nil,
max: Int? = nil,
newKey: String? = nil
) async throws -> AppwriteModels.AttributeInteger {
let apiPath: String = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}"
Expand Down Expand Up @@ -1435,9 +1425,7 @@ open class Databases: Service {

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

return try await client.call(
method: "GET",
Expand Down Expand Up @@ -1549,9 +1537,7 @@ open class Databases: Service {
"queries": queries
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.DocumentList<T> = { response in
return AppwriteModels.DocumentList.from(map: response as! [String: Any])
Expand Down Expand Up @@ -1594,6 +1580,7 @@ open class Databases: Service {
/// collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
///
///
/// @param String databaseId
/// @param String collectionId
Expand Down Expand Up @@ -1643,6 +1630,7 @@ open class Databases: Service {
/// collection resource using either a [server
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
/// API or directly from your database console.
///
///
/// @param String databaseId
/// @param String collectionId
Expand Down Expand Up @@ -1696,9 +1684,7 @@ open class Databases: Service {
"queries": queries
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.Document<T> = { response in
return AppwriteModels.Document.from(map: response as! [String: Any])
Expand Down Expand Up @@ -1869,9 +1855,7 @@ open class Databases: Service {
"queries": queries
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.IndexList = { response in
return AppwriteModels.IndexList.from(map: response as! [String: Any])
Expand Down Expand Up @@ -1957,9 +1941,7 @@ open class Databases: Service {

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

let apiHeaders: [String: String] = [
"content-type": "application/json"
]
let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.Index = { response in
return AppwriteModels.Index.from(map: response as! [String: Any])
Expand Down
Loading