@@ -9,19 +9,31 @@ import Foundation
99public struct TransformationTry : Codable , JSONEncodable {
1010 /// It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
1111 @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 ?
1315 /// The record to apply the given code to.
1416 public var sampleRecord : AnyCodable
1517 public var authentications : [ AuthenticationCreate ] ?
1618
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+ ) {
1826 self . code = code
27+ self . type = type
28+ self . input = input
1929 self . sampleRecord = sampleRecord
2030 self . authentications = authentications
2131 }
2232
2333 public enum CodingKeys : String , CodingKey , CaseIterable {
2434 case code
35+ case type
36+ case input
2537 case sampleRecord
2638 case authentications
2739 }
@@ -30,7 +42,9 @@ public struct TransformationTry: Codable, JSONEncodable {
3042
3143 public func encode( to encoder: Encoder ) throws {
3244 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)
3448 try container. encode ( self . sampleRecord, forKey: . sampleRecord)
3549 try container. encodeIfPresent ( self . authentications, forKey: . authentications)
3650 }
@@ -39,14 +53,18 @@ public struct TransformationTry: Codable, JSONEncodable {
3953extension TransformationTry : Equatable {
4054 public static func == ( lhs: TransformationTry , rhs: TransformationTry ) -> Bool {
4155 lhs. code == rhs. code &&
56+ lhs. type == rhs. type &&
57+ lhs. input == rhs. input &&
4258 lhs. sampleRecord == rhs. sampleRecord &&
4359 lhs. authentications == rhs. authentications
4460 }
4561}
4662
4763extension TransformationTry : Hashable {
4864 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)
5068 hasher. combine ( self . sampleRecord. hashValue)
5169 hasher. combine ( self . authentications? . hashValue)
5270 }
0 commit comments