Skip to content

Commit 3198f73

Browse files
feat(specs): update try transformation specs for no-code (generated)
algolia/api-clients-automation#4974 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Mehmet Ali Gok <[email protected]>
1 parent 69f23c5 commit 3198f73

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

Sources/Ingestion/Models/TransformationCreate.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public struct TransformationCreate: Codable, JSONEncodable {
1313
public var code: String?
1414
/// The uniquely identified name of your transformation.
1515
public var name: String
16-
public var type: TransformationType
17-
public var input: TransformationInput
16+
public var type: TransformationType?
17+
public var input: TransformationInput?
1818
/// A descriptive name for your transformation of what it does.
1919
public var description: String?
2020
/// The authentications associated with the current transformation.
@@ -23,8 +23,8 @@ public struct TransformationCreate: Codable, JSONEncodable {
2323
public init(
2424
code: String? = nil,
2525
name: String,
26-
type: TransformationType,
27-
input: TransformationInput,
26+
type: TransformationType? = nil,
27+
input: TransformationInput? = nil,
2828
description: String? = nil,
2929
authenticationIDs: [String]? = nil
3030
) {
@@ -51,8 +51,8 @@ public struct TransformationCreate: Codable, JSONEncodable {
5151
var container = encoder.container(keyedBy: CodingKeys.self)
5252
try container.encodeIfPresent(self.code, forKey: .code)
5353
try container.encode(self.name, forKey: .name)
54-
try container.encode(self.type, forKey: .type)
55-
try container.encode(self.input, forKey: .input)
54+
try container.encodeIfPresent(self.type, forKey: .type)
55+
try container.encodeIfPresent(self.input, forKey: .input)
5656
try container.encodeIfPresent(self.description, forKey: .description)
5757
try container.encodeIfPresent(self.authenticationIDs, forKey: .authenticationIDs)
5858
}
@@ -73,8 +73,8 @@ extension TransformationCreate: Hashable {
7373
public func hash(into hasher: inout Hasher) {
7474
hasher.combine(self.code?.hashValue)
7575
hasher.combine(self.name.hashValue)
76-
hasher.combine(self.type.hashValue)
77-
hasher.combine(self.input.hashValue)
76+
hasher.combine(self.type?.hashValue)
77+
hasher.combine(self.input?.hashValue)
7878
hasher.combine(self.description?.hashValue)
7979
hasher.combine(self.authenticationIDs?.hashValue)
8080
}

Sources/Ingestion/Models/TransformationTry.swift

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,31 @@ import Foundation
99
public 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 {
3953
extension 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

4763
extension 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

Comments
 (0)