mirror of
https://github.com/appwrite/sdk-for-swift.git
synced 2026-06-06 19:27:57 +00:00
71 lines
2.1 KiB
Swift
71 lines
2.1 KiB
Swift
import Foundation
|
|
import JSONCodable
|
|
|
|
/// OAuth2Zoho
|
|
open class OAuth2Zoho: Codable {
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case id = "$id"
|
|
case enabled = "enabled"
|
|
case clientId = "clientId"
|
|
case clientSecret = "clientSecret"
|
|
}
|
|
|
|
/// OAuth2 provider ID.
|
|
public let id: String
|
|
/// OAuth2 provider is active and can be used to create sessions.
|
|
public let enabled: Bool
|
|
/// Zoho OAuth2 client ID.
|
|
public let clientId: String
|
|
/// Zoho OAuth2 client secret.
|
|
public let clientSecret: String
|
|
|
|
init(
|
|
id: String,
|
|
enabled: Bool,
|
|
clientId: String,
|
|
clientSecret: String
|
|
) {
|
|
self.id = id
|
|
self.enabled = enabled
|
|
self.clientId = clientId
|
|
self.clientSecret = clientSecret
|
|
}
|
|
|
|
public required init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
self.id = try container.decode(String.self, forKey: .id)
|
|
self.enabled = try container.decode(Bool.self, forKey: .enabled)
|
|
self.clientId = try container.decode(String.self, forKey: .clientId)
|
|
self.clientSecret = try container.decode(String.self, forKey: .clientSecret)
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
|
try container.encode(id, forKey: .id)
|
|
try container.encode(enabled, forKey: .enabled)
|
|
try container.encode(clientId, forKey: .clientId)
|
|
try container.encode(clientSecret, forKey: .clientSecret)
|
|
}
|
|
|
|
public func toMap() -> [String: Any] {
|
|
return [
|
|
"$id": id as Any,
|
|
"enabled": enabled as Any,
|
|
"clientId": clientId as Any,
|
|
"clientSecret": clientSecret as Any
|
|
]
|
|
}
|
|
|
|
public static func from(map: [String: Any] ) -> OAuth2Zoho {
|
|
return OAuth2Zoho(
|
|
id: map["$id"] as! String,
|
|
enabled: map["enabled"] as! Bool,
|
|
clientId: map["clientId"] as! String,
|
|
clientSecret: map["clientSecret"] as! String
|
|
)
|
|
}
|
|
}
|