@@ -9,19 +9,31 @@ import Foundation
9
9
public struct TransformationTry : Codable , JSONEncodable {
10
10
/// It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
11
11
@available ( * , deprecated, message: " This property is deprecated. " )
12
- public var code : String
12
+ public var code : String ?
13
+ public var type : TransformationType ?
14
+ public var input : TransformationInput ?
13
15
/// The record to apply the given code to.
14
16
public var sampleRecord : AnyCodable
15
17
public var authentications : [ AuthenticationCreate ] ?
16
18
17
- public init ( code: String , sampleRecord: AnyCodable , authentications: [ AuthenticationCreate ] ? = nil ) {
19
+ public init (
20
+ code: String ? = nil ,
21
+ type: TransformationType ? = nil ,
22
+ input: TransformationInput ? = nil ,
23
+ sampleRecord: AnyCodable ,
24
+ authentications: [ AuthenticationCreate ] ? = nil
25
+ ) {
18
26
self . code = code
27
+ self . type = type
28
+ self . input = input
19
29
self . sampleRecord = sampleRecord
20
30
self . authentications = authentications
21
31
}
22
32
23
33
public enum CodingKeys : String , CodingKey , CaseIterable {
24
34
case code
35
+ case type
36
+ case input
25
37
case sampleRecord
26
38
case authentications
27
39
}
@@ -30,7 +42,9 @@ public struct TransformationTry: Codable, JSONEncodable {
30
42
31
43
public func encode( to encoder: Encoder ) throws {
32
44
var container = encoder. container ( keyedBy: CodingKeys . self)
33
- try container. encode ( self . code, forKey: . code)
45
+ try container. encodeIfPresent ( self . code, forKey: . code)
46
+ try container. encodeIfPresent ( self . type, forKey: . type)
47
+ try container. encodeIfPresent ( self . input, forKey: . input)
34
48
try container. encode ( self . sampleRecord, forKey: . sampleRecord)
35
49
try container. encodeIfPresent ( self . authentications, forKey: . authentications)
36
50
}
@@ -39,14 +53,18 @@ public struct TransformationTry: Codable, JSONEncodable {
39
53
extension TransformationTry : Equatable {
40
54
public static func == ( lhs: TransformationTry , rhs: TransformationTry ) -> Bool {
41
55
lhs. code == rhs. code &&
56
+ lhs. type == rhs. type &&
57
+ lhs. input == rhs. input &&
42
58
lhs. sampleRecord == rhs. sampleRecord &&
43
59
lhs. authentications == rhs. authentications
44
60
}
45
61
}
46
62
47
63
extension TransformationTry : Hashable {
48
64
public func hash( into hasher: inout Hasher ) {
49
- hasher. combine ( self . code. hashValue)
65
+ hasher. combine ( self . code? . hashValue)
66
+ hasher. combine ( self . type? . hashValue)
67
+ hasher. combine ( self . input? . hashValue)
50
68
hasher. combine ( self . sampleRecord. hashValue)
51
69
hasher. combine ( self . authentications? . hashValue)
52
70
}
0 commit comments