Skip to content

Commit 2a0b9c0

Browse files
algolia-botraed667
andcommitted
feat(specs): add (optional) _automaticInsights to search result (generated)
algolia/api-clients-automation#3688 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Raed <[email protected]>
1 parent dbc948b commit 2a0b9c0

File tree

5 files changed

+59
-7
lines changed

5 files changed

+59
-7
lines changed

Sources/Recommend/Models/RecommendBaseSearchResponse.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
5858
/// Unique identifier for the query. This is used for [click
5959
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
6060
public var queryID: String?
61+
/// Whether automatic events collection is enabled for the application.
62+
public var automaticInsights: Bool?
6163

6264
public init(
6365
abTestID: Int? = nil,
@@ -83,7 +85,8 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
8385
serverTimeMS: Int? = nil,
8486
serverUsed: String? = nil,
8587
userData: AnyCodable? = nil,
86-
queryID: String? = nil
88+
queryID: String? = nil,
89+
automaticInsights: Bool? = nil
8790
) {
8891
self.abTestID = abTestID
8992
self.abTestVariantID = abTestVariantID
@@ -109,6 +112,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
109112
self.serverUsed = serverUsed
110113
self.userData = userData
111114
self.queryID = queryID
115+
self.automaticInsights = automaticInsights
112116
}
113117

114118
public enum CodingKeys: String, CodingKey, CaseIterable {
@@ -136,6 +140,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
136140
case serverUsed
137141
case userData
138142
case queryID
143+
case automaticInsights = "_automaticInsights"
139144
}
140145

141146
public var additionalProperties: [String: AnyCodable] = [:]
@@ -204,13 +209,15 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
204209

205210
self.queryID = dictionary["queryID"]?.value as? String
206211

212+
self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool
213+
207214
for (key, value) in dictionary {
208215
switch key {
209216
case "abTestID", "abTestVariantID", "aroundLatLng", "automaticRadius", "exhaustive",
210217
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
211218
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
212219
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
213-
"queryID":
220+
"queryID", "automaticInsights":
214221
continue
215222
default:
216223
self.additionalProperties[key] = value
@@ -246,6 +253,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
246253
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
247254
try container.encodeIfPresent(self.userData, forKey: .userData)
248255
try container.encodeIfPresent(self.queryID, forKey: .queryID)
256+
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
249257
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
250258
try additionalPropertiesContainer.encodeMap(self.additionalProperties)
251259
}
@@ -279,6 +287,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
279287
self.serverUsed = try container.decodeIfPresent(String.self, forKey: .serverUsed)
280288
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
281289
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
290+
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
282291
var nonAdditionalPropertyKeys = Set<String>()
283292
nonAdditionalPropertyKeys.insert("abTestID")
284293
nonAdditionalPropertyKeys.insert("abTestVariantID")
@@ -304,6 +313,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
304313
nonAdditionalPropertyKeys.insert("serverUsed")
305314
nonAdditionalPropertyKeys.insert("userData")
306315
nonAdditionalPropertyKeys.insert("queryID")
316+
nonAdditionalPropertyKeys.insert("_automaticInsights")
307317
let additionalPropertiesContainer = try decoder.container(keyedBy: String.self)
308318
self.additionalProperties = try additionalPropertiesContainer.decodeMap(
309319
AnyCodable.self,
@@ -337,7 +347,8 @@ extension RecommendBaseSearchResponse: Equatable {
337347
lhs.serverTimeMS == rhs.serverTimeMS &&
338348
lhs.serverUsed == rhs.serverUsed &&
339349
lhs.userData == rhs.userData &&
340-
lhs.queryID == rhs.queryID
350+
lhs.queryID == rhs.queryID &&
351+
lhs.automaticInsights == rhs.automaticInsights
341352
&& lhs.additionalProperties == rhs.additionalProperties
342353
}
343354
}
@@ -368,6 +379,7 @@ extension RecommendBaseSearchResponse: Hashable {
368379
hasher.combine(self.serverUsed?.hashValue)
369380
hasher.combine(self.userData?.hashValue)
370381
hasher.combine(self.queryID?.hashValue)
382+
hasher.combine(self.automaticInsights?.hashValue)
371383
hasher.combine(self.additionalProperties.hashValue)
372384
}
373385
}

Sources/Recommend/Models/RecommendationsResults.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public struct RecommendationsResults: Codable, JSONEncodable {
5858
/// Unique identifier for the query. This is used for [click
5959
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
6060
public var queryID: String?
61+
/// Whether automatic events collection is enabled for the application.
62+
public var automaticInsights: Bool?
6163
/// Page of search results to retrieve.
6264
public var page: Int
6365
/// Number of results (hits).
@@ -93,6 +95,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
9395
serverUsed: String? = nil,
9496
userData: AnyCodable? = nil,
9597
queryID: String? = nil,
98+
automaticInsights: Bool? = nil,
9699
page: Int,
97100
nbHits: Int,
98101
nbPages: Int,
@@ -123,6 +126,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
123126
self.serverUsed = serverUsed
124127
self.userData = userData
125128
self.queryID = queryID
129+
self.automaticInsights = automaticInsights
126130
self.page = page
127131
self.nbHits = nbHits
128132
self.nbPages = nbPages
@@ -155,6 +159,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
155159
case serverUsed
156160
case userData
157161
case queryID
162+
case automaticInsights = "_automaticInsights"
158163
case page
159164
case nbHits
160165
case nbPages
@@ -190,6 +195,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
190195
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
191196
try container.encodeIfPresent(self.userData, forKey: .userData)
192197
try container.encodeIfPresent(self.queryID, forKey: .queryID)
198+
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
193199
try container.encode(self.page, forKey: .page)
194200
try container.encode(self.nbHits, forKey: .nbHits)
195201
try container.encode(self.nbPages, forKey: .nbPages)
@@ -224,6 +230,7 @@ extension RecommendationsResults: Equatable {
224230
lhs.serverUsed == rhs.serverUsed &&
225231
lhs.userData == rhs.userData &&
226232
lhs.queryID == rhs.queryID &&
233+
lhs.automaticInsights == rhs.automaticInsights &&
227234
lhs.page == rhs.page &&
228235
lhs.nbHits == rhs.nbHits &&
229236
lhs.nbPages == rhs.nbPages &&
@@ -258,6 +265,7 @@ extension RecommendationsResults: Hashable {
258265
hasher.combine(self.serverUsed?.hashValue)
259266
hasher.combine(self.userData?.hashValue)
260267
hasher.combine(self.queryID?.hashValue)
268+
hasher.combine(self.automaticInsights?.hashValue)
261269
hasher.combine(self.page.hashValue)
262270
hasher.combine(self.nbHits.hashValue)
263271
hasher.combine(self.nbPages.hashValue)

Sources/Search/Models/BrowseResponse.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
5858
/// Unique identifier for the query. This is used for [click
5959
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
6060
public var queryID: String?
61+
/// Whether automatic events collection is enabled for the application.
62+
public var automaticInsights: Bool?
6163
/// Page of search results to retrieve.
6264
public var page: Int?
6365
/// Number of results (hits).
@@ -102,6 +104,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
102104
serverUsed: String? = nil,
103105
userData: AnyCodable? = nil,
104106
queryID: String? = nil,
107+
automaticInsights: Bool? = nil,
105108
page: Int? = nil,
106109
nbHits: Int? = nil,
107110
nbPages: Int? = nil,
@@ -135,6 +138,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
135138
self.serverUsed = serverUsed
136139
self.userData = userData
137140
self.queryID = queryID
141+
self.automaticInsights = automaticInsights
138142
self.page = page
139143
self.nbHits = nbHits
140144
self.nbPages = nbPages
@@ -170,6 +174,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
170174
case serverUsed
171175
case userData
172176
case queryID
177+
case automaticInsights = "_automaticInsights"
173178
case page
174179
case nbHits
175180
case nbPages
@@ -208,6 +213,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
208213
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
209214
try container.encodeIfPresent(self.userData, forKey: .userData)
210215
try container.encodeIfPresent(self.queryID, forKey: .queryID)
216+
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
211217
try container.encodeIfPresent(self.page, forKey: .page)
212218
try container.encodeIfPresent(self.nbHits, forKey: .nbHits)
213219
try container.encodeIfPresent(self.nbPages, forKey: .nbPages)
@@ -245,6 +251,7 @@ extension BrowseResponse: Equatable where T: Equatable {
245251
lhs.serverUsed == rhs.serverUsed &&
246252
lhs.userData == rhs.userData &&
247253
lhs.queryID == rhs.queryID &&
254+
lhs.automaticInsights == rhs.automaticInsights &&
248255
lhs.page == rhs.page &&
249256
lhs.nbHits == rhs.nbHits &&
250257
lhs.nbPages == rhs.nbPages &&
@@ -282,6 +289,7 @@ extension BrowseResponse: Hashable where T: Hashable {
282289
hasher.combine(self.serverUsed?.hashValue)
283290
hasher.combine(self.userData?.hashValue)
284291
hasher.combine(self.queryID?.hashValue)
292+
hasher.combine(self.automaticInsights?.hashValue)
285293
hasher.combine(self.page?.hashValue)
286294
hasher.combine(self.nbHits?.hashValue)
287295
hasher.combine(self.nbPages?.hashValue)

Sources/Search/Models/SearchBaseSearchResponse.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
5858
/// Unique identifier for the query. This is used for [click
5959
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
6060
public var queryID: String?
61+
/// Whether automatic events collection is enabled for the application.
62+
public var automaticInsights: Bool?
6163

6264
public init(
6365
abTestID: Int? = nil,
@@ -83,7 +85,8 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
8385
serverTimeMS: Int? = nil,
8486
serverUsed: String? = nil,
8587
userData: AnyCodable? = nil,
86-
queryID: String? = nil
88+
queryID: String? = nil,
89+
automaticInsights: Bool? = nil
8790
) {
8891
self.abTestID = abTestID
8992
self.abTestVariantID = abTestVariantID
@@ -109,6 +112,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
109112
self.serverUsed = serverUsed
110113
self.userData = userData
111114
self.queryID = queryID
115+
self.automaticInsights = automaticInsights
112116
}
113117

114118
public enum CodingKeys: String, CodingKey, CaseIterable {
@@ -136,6 +140,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
136140
case serverUsed
137141
case userData
138142
case queryID
143+
case automaticInsights = "_automaticInsights"
139144
}
140145

141146
public var additionalProperties: [String: AnyCodable] = [:]
@@ -204,13 +209,15 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
204209

205210
self.queryID = dictionary["queryID"]?.value as? String
206211

212+
self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool
213+
207214
for (key, value) in dictionary {
208215
switch key {
209216
case "abTestID", "abTestVariantID", "aroundLatLng", "automaticRadius", "exhaustive",
210217
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
211218
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
212219
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
213-
"queryID":
220+
"queryID", "automaticInsights":
214221
continue
215222
default:
216223
self.additionalProperties[key] = value
@@ -246,6 +253,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
246253
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
247254
try container.encodeIfPresent(self.userData, forKey: .userData)
248255
try container.encodeIfPresent(self.queryID, forKey: .queryID)
256+
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
249257
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
250258
try additionalPropertiesContainer.encodeMap(self.additionalProperties)
251259
}
@@ -279,6 +287,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
279287
self.serverUsed = try container.decodeIfPresent(String.self, forKey: .serverUsed)
280288
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
281289
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
290+
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
282291
var nonAdditionalPropertyKeys = Set<String>()
283292
nonAdditionalPropertyKeys.insert("abTestID")
284293
nonAdditionalPropertyKeys.insert("abTestVariantID")
@@ -304,6 +313,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
304313
nonAdditionalPropertyKeys.insert("serverUsed")
305314
nonAdditionalPropertyKeys.insert("userData")
306315
nonAdditionalPropertyKeys.insert("queryID")
316+
nonAdditionalPropertyKeys.insert("_automaticInsights")
307317
let additionalPropertiesContainer = try decoder.container(keyedBy: String.self)
308318
self.additionalProperties = try additionalPropertiesContainer.decodeMap(
309319
AnyCodable.self,
@@ -337,7 +347,8 @@ extension SearchBaseSearchResponse: Equatable {
337347
lhs.serverTimeMS == rhs.serverTimeMS &&
338348
lhs.serverUsed == rhs.serverUsed &&
339349
lhs.userData == rhs.userData &&
340-
lhs.queryID == rhs.queryID
350+
lhs.queryID == rhs.queryID &&
351+
lhs.automaticInsights == rhs.automaticInsights
341352
&& lhs.additionalProperties == rhs.additionalProperties
342353
}
343354
}
@@ -368,6 +379,7 @@ extension SearchBaseSearchResponse: Hashable {
368379
hasher.combine(self.serverUsed?.hashValue)
369380
hasher.combine(self.userData?.hashValue)
370381
hasher.combine(self.queryID?.hashValue)
382+
hasher.combine(self.automaticInsights?.hashValue)
371383
hasher.combine(self.additionalProperties.hashValue)
372384
}
373385
}

Sources/Search/Models/SearchResponse.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
5858
/// Unique identifier for the query. This is used for [click
5959
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
6060
public var queryID: String?
61+
/// Whether automatic events collection is enabled for the application.
62+
public var automaticInsights: Bool?
6163
/// Page of search results to retrieve.
6264
public var page: Int
6365
/// Number of results (hits).
@@ -99,6 +101,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
99101
serverUsed: String? = nil,
100102
userData: AnyCodable? = nil,
101103
queryID: String? = nil,
104+
automaticInsights: Bool? = nil,
102105
page: Int,
103106
nbHits: Int,
104107
nbPages: Int,
@@ -131,6 +134,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
131134
self.serverUsed = serverUsed
132135
self.userData = userData
133136
self.queryID = queryID
137+
self.automaticInsights = automaticInsights
134138
self.page = page
135139
self.nbHits = nbHits
136140
self.nbPages = nbPages
@@ -165,6 +169,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
165169
case serverUsed
166170
case userData
167171
case queryID
172+
case automaticInsights = "_automaticInsights"
168173
case page
169174
case nbHits
170175
case nbPages
@@ -240,6 +245,8 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
240245

241246
self.queryID = dictionary["queryID"]?.value as? String
242247

248+
self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool
249+
243250
guard let page = dictionary["page"]?.value as? Int else {
244251
throw GenericError(description: "Failed to cast")
245252
}
@@ -274,7 +281,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
274281
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
275282
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
276283
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
277-
"queryID", "page", "nbHits", "nbPages", "hitsPerPage", "hits", "query", "params":
284+
"queryID", "automaticInsights", "page", "nbHits", "nbPages", "hitsPerPage", "hits", "query", "params":
278285
continue
279286
default:
280287
self.additionalProperties[key] = value
@@ -310,6 +317,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
310317
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
311318
try container.encodeIfPresent(self.userData, forKey: .userData)
312319
try container.encodeIfPresent(self.queryID, forKey: .queryID)
320+
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
313321
try container.encode(self.page, forKey: .page)
314322
try container.encode(self.nbHits, forKey: .nbHits)
315323
try container.encode(self.nbPages, forKey: .nbPages)
@@ -350,6 +358,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
350358
self.serverUsed = try container.decodeIfPresent(String.self, forKey: .serverUsed)
351359
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
352360
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
361+
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
353362
self.page = try container.decode(Int.self, forKey: .page)
354363
self.nbHits = try container.decode(Int.self, forKey: .nbHits)
355364
self.nbPages = try container.decode(Int.self, forKey: .nbPages)
@@ -382,6 +391,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
382391
nonAdditionalPropertyKeys.insert("serverUsed")
383392
nonAdditionalPropertyKeys.insert("userData")
384393
nonAdditionalPropertyKeys.insert("queryID")
394+
nonAdditionalPropertyKeys.insert("_automaticInsights")
385395
nonAdditionalPropertyKeys.insert("page")
386396
nonAdditionalPropertyKeys.insert("nbHits")
387397
nonAdditionalPropertyKeys.insert("nbPages")
@@ -423,6 +433,7 @@ extension SearchResponse: Equatable where T: Equatable {
423433
lhs.serverUsed == rhs.serverUsed &&
424434
lhs.userData == rhs.userData &&
425435
lhs.queryID == rhs.queryID &&
436+
lhs.automaticInsights == rhs.automaticInsights &&
426437
lhs.page == rhs.page &&
427438
lhs.nbHits == rhs.nbHits &&
428439
lhs.nbPages == rhs.nbPages &&
@@ -460,6 +471,7 @@ extension SearchResponse: Hashable where T: Hashable {
460471
hasher.combine(self.serverUsed?.hashValue)
461472
hasher.combine(self.userData?.hashValue)
462473
hasher.combine(self.queryID?.hashValue)
474+
hasher.combine(self.automaticInsights?.hashValue)
463475
hasher.combine(self.page.hashValue)
464476
hasher.combine(self.nbHits.hashValue)
465477
hasher.combine(self.nbPages.hashValue)

0 commit comments

Comments
 (0)