Skip to content

Commit

Permalink
fix(swift): wait for api key helper update operation
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3340

Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
  • Loading branch information
algolia-bot and Fluf22 committed Jul 9, 2024
1 parent ffe1c1e commit c666d86
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions Sources/Search/Extra/SearchClientExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,23 @@ public extension SearchClient {
try await self.getApiKey(key: key, requestOptions: requestOptions)
},
validate: { response in
if apiKey.description != nil, apiKey.description != response.description {
if apiKey.description != response.description {
return false
}

if apiKey.queryParameters != nil, apiKey.queryParameters != response.queryParameters {
if apiKey.queryParameters != response.queryParameters {
return false
}

if apiKey.maxHitsPerQuery != nil, apiKey.maxHitsPerQuery != response.maxHitsPerQuery {
if apiKey.maxHitsPerQuery != response.maxHitsPerQuery {
return false
}

if apiKey.maxQueriesPerIPPerHour != nil,
apiKey.maxQueriesPerIPPerHour != response.maxQueriesPerIPPerHour {
if apiKey.maxQueriesPerIPPerHour != response.maxQueriesPerIPPerHour {
return false
}

if apiKey.validity != nil, apiKey.validity != response.validity {
if apiKey.validity != response.validity {
return false
}

Expand All @@ -153,20 +152,16 @@ public extension SearchClient {
return false
}

if let apiKeyIndexes = apiKey.indexes {
let expectedIndexes = apiKeyIndexes.sorted { $0 > $1 }
let responseIndexes = response.indexes?.sorted { $0 > $1 }
if expectedIndexes != responseIndexes {
return false
}
let expectedIndexes = apiKey.indexes?.sorted { $0 > $1 }
let responseIndexes = response.indexes?.sorted { $0 > $1 }
if expectedIndexes != responseIndexes {
return false
}

if let apiKeyReferers = apiKey.referers {
let expectedReferers = apiKeyReferers.sorted { $0 > $1 }
let responseReferers = response.referers?.sorted { $0 > $1 }
if expectedReferers != responseReferers {
return false
}
let expectedReferers = apiKey.referers?.sorted { $0 > $1 }
let responseReferers = response.referers?.sorted { $0 > $1 }
if expectedReferers != responseReferers {
return false
}

return true
Expand Down

0 comments on commit c666d86

Please # to comment.