mirror of
https://github.com/appwrite/sdk-for-swift.git
synced 2026-04-07 19:17:48 +00:00
1fb0191d08
* Breaking: Renamed `AppwriteEnums.IndexType` to `AppwriteEnums.DatabasesIndexType` in `Databases`\n* Added `DocumentsDB` service with list/create/get/update/delete and transaction endpoints\n* Added impersonation support: `setImpersonateUserId`, `setImpersonateUserEmail`, `setImpersonateUserPhone`\n* Updated `x-sdk-version` to `15.1.0` and `x-appwrite-response-format` to `1.9.0`\n* Updated README badge to display API version `1.9.0`
53 lines
1.4 KiB
Swift
53 lines
1.4 KiB
Swift
import Foundation
|
|
import JSONCodable
|
|
|
|
/// Webhooks List
|
|
open class WebhookList: Codable {
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case total = "total"
|
|
case webhooks = "webhooks"
|
|
}
|
|
|
|
/// Total number of webhooks that matched your query.
|
|
public let total: Int
|
|
/// List of webhooks.
|
|
public let webhooks: [Webhook]
|
|
|
|
init(
|
|
total: Int,
|
|
webhooks: [Webhook]
|
|
) {
|
|
self.total = total
|
|
self.webhooks = webhooks
|
|
}
|
|
|
|
public required init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
self.total = try container.decode(Int.self, forKey: .total)
|
|
self.webhooks = try container.decode([Webhook].self, forKey: .webhooks)
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
|
try container.encode(total, forKey: .total)
|
|
try container.encode(webhooks, forKey: .webhooks)
|
|
}
|
|
|
|
public func toMap() -> [String: Any] {
|
|
return [
|
|
"total": total as Any,
|
|
"webhooks": webhooks.map { $0.toMap() } as Any
|
|
]
|
|
}
|
|
|
|
public static func from(map: [String: Any] ) -> WebhookList {
|
|
return WebhookList(
|
|
total: map["total"] as! Int,
|
|
webhooks: (map["webhooks"] as! [[String: Any]]).map { Webhook.from(map: $0) }
|
|
)
|
|
}
|
|
}
|