mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-06-10 09:19:22 +00:00
9b3b3692ee
* Support for follow requests (#321) * Run SwiftFormat Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
44 lines
1,000 B
Swift
44 lines
1,000 B
Swift
import Foundation
|
|
|
|
public struct Poll: Codable, Equatable, Hashable {
|
|
public static func == (lhs: Poll, rhs: Poll) -> Bool {
|
|
lhs.id == rhs.id
|
|
}
|
|
|
|
public func hash(into hasher: inout Hasher) {
|
|
hasher.combine(id)
|
|
}
|
|
|
|
public struct Option: Identifiable, Codable {
|
|
enum CodingKeys: String, CodingKey {
|
|
case title, votesCount
|
|
}
|
|
|
|
public var id = UUID().uuidString
|
|
public let title: String
|
|
public let votesCount: Int
|
|
}
|
|
|
|
public let id: String
|
|
public let expiresAt: NullableString
|
|
public let expired: Bool
|
|
public let multiple: Bool
|
|
public let votesCount: Int
|
|
public let voted: Bool?
|
|
public let ownVotes: [Int]?
|
|
public let options: [Option]
|
|
}
|
|
|
|
public struct NullableString: Codable, Equatable, Hashable {
|
|
public let value: String?
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
do {
|
|
let container = try decoder.singleValueContainer()
|
|
self.value = try container.decode(String.self)
|
|
} catch {
|
|
self.value = nil
|
|
}
|
|
}
|
|
}
|