Newer
Older
1
2
3
4
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
import Foundation
public struct FileSend: Equatable {
public init(
name: String,
type: String,
preview: Data,
contents: Data
) {
self.name = name
self.type = type
self.preview = preview
self.contents = contents
}
public var name: String
public var type: String
public var preview: Data
public var contents: Data
}
extension FileSend: Codable {
enum CodingKeys: String, CodingKey {
case name = "Name"
case type = "Type"
case preview = "Preview"
case contents = "Contents"
}
public static func decode(_ data: Data) throws -> Self {
try JSONDecoder().decode(Self.self, from: data)
}
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}