Newer
Older
import Foundation
public struct NotificationReport: Equatable {
public enum ReportType: String, Equatable, CaseIterable {
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
case `default`
case request
case reset
case confirm
case silent
case e2e
case group
case endFT
case groupRQ
}
public init(
forMe: Bool,
type: NotificationReport.ReportType,
source: Data
) {
self.forMe = forMe
self.type = type
self.source = source
}
public var forMe: Bool
public var type: ReportType
public var source: Data
}
extension NotificationReport.ReportType: Codable {}
extension NotificationReport: Codable {
enum CodingKeys: String, CodingKey {
case forMe = "ForMe"
case type = "Type"
case source = "Source"
}
public static func decode(_ data: Data) throws -> Self {
try JSONDecoder().decode(Self.self, from: data)
}
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
extension Array where Element == NotificationReport {
public static func decode(_ data: Data) throws -> Self {
try JSONDecoder().decode(Self.self, from: data)
}
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}