Skip to content

Commit

Permalink
feat(specs): add (optional) _automaticInsights to search result (gene…
Browse files Browse the repository at this point in the history
…rated)

algolia/api-clients-automation#3688

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Raed <raed.chammam@algolia.com>
  • Loading branch information
algolia-bot and raed667 committed Sep 11, 2024
1 parent dbc948b commit 2a0b9c0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
18 changes: 15 additions & 3 deletions Sources/Recommend/Models/RecommendBaseSearchResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
/// Unique identifier for the query. This is used for [click
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
public var queryID: String?
/// Whether automatic events collection is enabled for the application.
public var automaticInsights: Bool?

public init(
abTestID: Int? = nil,
Expand All @@ -83,7 +85,8 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
serverTimeMS: Int? = nil,
serverUsed: String? = nil,
userData: AnyCodable? = nil,
queryID: String? = nil
queryID: String? = nil,
automaticInsights: Bool? = nil
) {
self.abTestID = abTestID
self.abTestVariantID = abTestVariantID
Expand All @@ -109,6 +112,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
self.serverUsed = serverUsed
self.userData = userData
self.queryID = queryID
self.automaticInsights = automaticInsights
}

public enum CodingKeys: String, CodingKey, CaseIterable {
Expand Down Expand Up @@ -136,6 +140,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
case serverUsed
case userData
case queryID
case automaticInsights = "_automaticInsights"
}

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

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

self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool

for (key, value) in dictionary {
switch key {
case "abTestID", "abTestVariantID", "aroundLatLng", "automaticRadius", "exhaustive",
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
"queryID":
"queryID", "automaticInsights":
continue
default:
self.additionalProperties[key] = value
Expand Down Expand Up @@ -246,6 +253,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
try container.encodeIfPresent(self.userData, forKey: .userData)
try container.encodeIfPresent(self.queryID, forKey: .queryID)
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
try additionalPropertiesContainer.encodeMap(self.additionalProperties)
}
Expand Down Expand Up @@ -279,6 +287,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
self.serverUsed = try container.decodeIfPresent(String.self, forKey: .serverUsed)
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
var nonAdditionalPropertyKeys = Set<String>()
nonAdditionalPropertyKeys.insert("abTestID")
nonAdditionalPropertyKeys.insert("abTestVariantID")
Expand All @@ -304,6 +313,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
nonAdditionalPropertyKeys.insert("serverUsed")
nonAdditionalPropertyKeys.insert("userData")
nonAdditionalPropertyKeys.insert("queryID")
nonAdditionalPropertyKeys.insert("_automaticInsights")
let additionalPropertiesContainer = try decoder.container(keyedBy: String.self)
self.additionalProperties = try additionalPropertiesContainer.decodeMap(
AnyCodable.self,
Expand Down Expand Up @@ -337,7 +347,8 @@ extension RecommendBaseSearchResponse: Equatable {
lhs.serverTimeMS == rhs.serverTimeMS &&
lhs.serverUsed == rhs.serverUsed &&
lhs.userData == rhs.userData &&
lhs.queryID == rhs.queryID
lhs.queryID == rhs.queryID &&
lhs.automaticInsights == rhs.automaticInsights
&& lhs.additionalProperties == rhs.additionalProperties
}
}
Expand Down Expand Up @@ -368,6 +379,7 @@ extension RecommendBaseSearchResponse: Hashable {
hasher.combine(self.serverUsed?.hashValue)
hasher.combine(self.userData?.hashValue)
hasher.combine(self.queryID?.hashValue)
hasher.combine(self.automaticInsights?.hashValue)
hasher.combine(self.additionalProperties.hashValue)
}
}
8 changes: 8 additions & 0 deletions Sources/Recommend/Models/RecommendationsResults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public struct RecommendationsResults: Codable, JSONEncodable {
/// Unique identifier for the query. This is used for [click
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
public var queryID: String?
/// Whether automatic events collection is enabled for the application.
public var automaticInsights: Bool?
/// Page of search results to retrieve.
public var page: Int
/// Number of results (hits).
Expand Down Expand Up @@ -93,6 +95,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
serverUsed: String? = nil,
userData: AnyCodable? = nil,
queryID: String? = nil,
automaticInsights: Bool? = nil,
page: Int,
nbHits: Int,
nbPages: Int,
Expand Down Expand Up @@ -123,6 +126,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
self.serverUsed = serverUsed
self.userData = userData
self.queryID = queryID
self.automaticInsights = automaticInsights
self.page = page
self.nbHits = nbHits
self.nbPages = nbPages
Expand Down Expand Up @@ -155,6 +159,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
case serverUsed
case userData
case queryID
case automaticInsights = "_automaticInsights"
case page
case nbHits
case nbPages
Expand Down Expand Up @@ -190,6 +195,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
try container.encodeIfPresent(self.userData, forKey: .userData)
try container.encodeIfPresent(self.queryID, forKey: .queryID)
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
try container.encode(self.page, forKey: .page)
try container.encode(self.nbHits, forKey: .nbHits)
try container.encode(self.nbPages, forKey: .nbPages)
Expand Down Expand Up @@ -224,6 +230,7 @@ extension RecommendationsResults: Equatable {
lhs.serverUsed == rhs.serverUsed &&
lhs.userData == rhs.userData &&
lhs.queryID == rhs.queryID &&
lhs.automaticInsights == rhs.automaticInsights &&
lhs.page == rhs.page &&
lhs.nbHits == rhs.nbHits &&
lhs.nbPages == rhs.nbPages &&
Expand Down Expand Up @@ -258,6 +265,7 @@ extension RecommendationsResults: Hashable {
hasher.combine(self.serverUsed?.hashValue)
hasher.combine(self.userData?.hashValue)
hasher.combine(self.queryID?.hashValue)
hasher.combine(self.automaticInsights?.hashValue)
hasher.combine(self.page.hashValue)
hasher.combine(self.nbHits.hashValue)
hasher.combine(self.nbPages.hashValue)
Expand Down
8 changes: 8 additions & 0 deletions Sources/Search/Models/BrowseResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
/// Unique identifier for the query. This is used for [click
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
public var queryID: String?
/// Whether automatic events collection is enabled for the application.
public var automaticInsights: Bool?
/// Page of search results to retrieve.
public var page: Int?
/// Number of results (hits).
Expand Down Expand Up @@ -102,6 +104,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
serverUsed: String? = nil,
userData: AnyCodable? = nil,
queryID: String? = nil,
automaticInsights: Bool? = nil,
page: Int? = nil,
nbHits: Int? = nil,
nbPages: Int? = nil,
Expand Down Expand Up @@ -135,6 +138,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
self.serverUsed = serverUsed
self.userData = userData
self.queryID = queryID
self.automaticInsights = automaticInsights
self.page = page
self.nbHits = nbHits
self.nbPages = nbPages
Expand Down Expand Up @@ -170,6 +174,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
case serverUsed
case userData
case queryID
case automaticInsights = "_automaticInsights"
case page
case nbHits
case nbPages
Expand Down Expand Up @@ -208,6 +213,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
try container.encodeIfPresent(self.userData, forKey: .userData)
try container.encodeIfPresent(self.queryID, forKey: .queryID)
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
try container.encodeIfPresent(self.page, forKey: .page)
try container.encodeIfPresent(self.nbHits, forKey: .nbHits)
try container.encodeIfPresent(self.nbPages, forKey: .nbPages)
Expand Down Expand Up @@ -245,6 +251,7 @@ extension BrowseResponse: Equatable where T: Equatable {
lhs.serverUsed == rhs.serverUsed &&
lhs.userData == rhs.userData &&
lhs.queryID == rhs.queryID &&
lhs.automaticInsights == rhs.automaticInsights &&
lhs.page == rhs.page &&
lhs.nbHits == rhs.nbHits &&
lhs.nbPages == rhs.nbPages &&
Expand Down Expand Up @@ -282,6 +289,7 @@ extension BrowseResponse: Hashable where T: Hashable {
hasher.combine(self.serverUsed?.hashValue)
hasher.combine(self.userData?.hashValue)
hasher.combine(self.queryID?.hashValue)
hasher.combine(self.automaticInsights?.hashValue)
hasher.combine(self.page?.hashValue)
hasher.combine(self.nbHits?.hashValue)
hasher.combine(self.nbPages?.hashValue)
Expand Down
18 changes: 15 additions & 3 deletions Sources/Search/Models/SearchBaseSearchResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
/// Unique identifier for the query. This is used for [click
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
public var queryID: String?
/// Whether automatic events collection is enabled for the application.
public var automaticInsights: Bool?

public init(
abTestID: Int? = nil,
Expand All @@ -83,7 +85,8 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
serverTimeMS: Int? = nil,
serverUsed: String? = nil,
userData: AnyCodable? = nil,
queryID: String? = nil
queryID: String? = nil,
automaticInsights: Bool? = nil
) {
self.abTestID = abTestID
self.abTestVariantID = abTestVariantID
Expand All @@ -109,6 +112,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
self.serverUsed = serverUsed
self.userData = userData
self.queryID = queryID
self.automaticInsights = automaticInsights
}

public enum CodingKeys: String, CodingKey, CaseIterable {
Expand Down Expand Up @@ -136,6 +140,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
case serverUsed
case userData
case queryID
case automaticInsights = "_automaticInsights"
}

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

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

self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool

for (key, value) in dictionary {
switch key {
case "abTestID", "abTestVariantID", "aroundLatLng", "automaticRadius", "exhaustive",
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
"queryID":
"queryID", "automaticInsights":
continue
default:
self.additionalProperties[key] = value
Expand Down Expand Up @@ -246,6 +253,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
try container.encodeIfPresent(self.userData, forKey: .userData)
try container.encodeIfPresent(self.queryID, forKey: .queryID)
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
try additionalPropertiesContainer.encodeMap(self.additionalProperties)
}
Expand Down Expand Up @@ -279,6 +287,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
self.serverUsed = try container.decodeIfPresent(String.self, forKey: .serverUsed)
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
var nonAdditionalPropertyKeys = Set<String>()
nonAdditionalPropertyKeys.insert("abTestID")
nonAdditionalPropertyKeys.insert("abTestVariantID")
Expand All @@ -304,6 +313,7 @@ public struct SearchBaseSearchResponse: Codable, JSONEncodable {
nonAdditionalPropertyKeys.insert("serverUsed")
nonAdditionalPropertyKeys.insert("userData")
nonAdditionalPropertyKeys.insert("queryID")
nonAdditionalPropertyKeys.insert("_automaticInsights")
let additionalPropertiesContainer = try decoder.container(keyedBy: String.self)
self.additionalProperties = try additionalPropertiesContainer.decodeMap(
AnyCodable.self,
Expand Down Expand Up @@ -337,7 +347,8 @@ extension SearchBaseSearchResponse: Equatable {
lhs.serverTimeMS == rhs.serverTimeMS &&
lhs.serverUsed == rhs.serverUsed &&
lhs.userData == rhs.userData &&
lhs.queryID == rhs.queryID
lhs.queryID == rhs.queryID &&
lhs.automaticInsights == rhs.automaticInsights
&& lhs.additionalProperties == rhs.additionalProperties
}
}
Expand Down Expand Up @@ -368,6 +379,7 @@ extension SearchBaseSearchResponse: Hashable {
hasher.combine(self.serverUsed?.hashValue)
hasher.combine(self.userData?.hashValue)
hasher.combine(self.queryID?.hashValue)
hasher.combine(self.automaticInsights?.hashValue)
hasher.combine(self.additionalProperties.hashValue)
}
}
14 changes: 13 additions & 1 deletion Sources/Search/Models/SearchResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
/// Unique identifier for the query. This is used for [click
/// analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
public var queryID: String?
/// Whether automatic events collection is enabled for the application.
public var automaticInsights: Bool?
/// Page of search results to retrieve.
public var page: Int
/// Number of results (hits).
Expand Down Expand Up @@ -99,6 +101,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
serverUsed: String? = nil,
userData: AnyCodable? = nil,
queryID: String? = nil,
automaticInsights: Bool? = nil,
page: Int,
nbHits: Int,
nbPages: Int,
Expand Down Expand Up @@ -131,6 +134,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
self.serverUsed = serverUsed
self.userData = userData
self.queryID = queryID
self.automaticInsights = automaticInsights
self.page = page
self.nbHits = nbHits
self.nbPages = nbPages
Expand Down Expand Up @@ -165,6 +169,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
case serverUsed
case userData
case queryID
case automaticInsights = "_automaticInsights"
case page
case nbHits
case nbPages
Expand Down Expand Up @@ -240,6 +245,8 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {

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

self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool

guard let page = dictionary["page"]?.value as? Int else {
throw GenericError(description: "Failed to cast")
}
Expand Down Expand Up @@ -274,7 +281,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
"queryID", "page", "nbHits", "nbPages", "hitsPerPage", "hits", "query", "params":
"queryID", "automaticInsights", "page", "nbHits", "nbPages", "hitsPerPage", "hits", "query", "params":
continue
default:
self.additionalProperties[key] = value
Expand Down Expand Up @@ -310,6 +317,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
try container.encodeIfPresent(self.serverUsed, forKey: .serverUsed)
try container.encodeIfPresent(self.userData, forKey: .userData)
try container.encodeIfPresent(self.queryID, forKey: .queryID)
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
try container.encode(self.page, forKey: .page)
try container.encode(self.nbHits, forKey: .nbHits)
try container.encode(self.nbPages, forKey: .nbPages)
Expand Down Expand Up @@ -350,6 +358,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
self.serverUsed = try container.decodeIfPresent(String.self, forKey: .serverUsed)
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
self.page = try container.decode(Int.self, forKey: .page)
self.nbHits = try container.decode(Int.self, forKey: .nbHits)
self.nbPages = try container.decode(Int.self, forKey: .nbPages)
Expand Down Expand Up @@ -382,6 +391,7 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
nonAdditionalPropertyKeys.insert("serverUsed")
nonAdditionalPropertyKeys.insert("userData")
nonAdditionalPropertyKeys.insert("queryID")
nonAdditionalPropertyKeys.insert("_automaticInsights")
nonAdditionalPropertyKeys.insert("page")
nonAdditionalPropertyKeys.insert("nbHits")
nonAdditionalPropertyKeys.insert("nbPages")
Expand Down Expand Up @@ -423,6 +433,7 @@ extension SearchResponse: Equatable where T: Equatable {
lhs.serverUsed == rhs.serverUsed &&
lhs.userData == rhs.userData &&
lhs.queryID == rhs.queryID &&
lhs.automaticInsights == rhs.automaticInsights &&
lhs.page == rhs.page &&
lhs.nbHits == rhs.nbHits &&
lhs.nbPages == rhs.nbPages &&
Expand Down Expand Up @@ -460,6 +471,7 @@ extension SearchResponse: Hashable where T: Hashable {
hasher.combine(self.serverUsed?.hashValue)
hasher.combine(self.userData?.hashValue)
hasher.combine(self.queryID?.hashValue)
hasher.combine(self.automaticInsights?.hashValue)
hasher.combine(self.page.hashValue)
hasher.combine(self.nbHits.hashValue)
hasher.combine(self.nbPages.hashValue)
Expand Down

0 comments on commit 2a0b9c0

Please sign in to comment.