Skip to content

Commit 6d1ab95

Browse files
chore: update host for Personalization Client (#791)
* chore: add convenient eu Region variable for personalization API
1 parent 23b1989 commit 6d1ab95

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Sources/AlgoliaSearchClient/Models/Common/Region.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
//
55
// Created by Vladislav Fitc on 23/04/2020.
66
//
7+
// swiftlint:disable identifier_name
78

89
import Foundation
910

1011
public struct Region: StringOption, ProvidingCustomOption {
1112

1213
public static var us: Self { .init(rawValue: #function) }
14+
15+
/// European (Germany) region for Insights and Analytics APIs
1316
public static var de: Self { .init(rawValue: #function) }
1417

18+
/// European region for Personalization API
19+
public static var eu: Self { .init(rawValue: #function) }
20+
1521
public let rawValue: String
1622

1723
public init(rawValue: String) {

Sources/AlgoliaSearchClient/Models/Internal/Hosts.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,17 @@ public struct Hosts {
3434
return [.init(url: URL(string: "insights\(regionComponent).algolia.io")!)]
3535
}
3636

37+
@available(*, deprecated, renamed: "personalization(forRegion:)")
3738
public static func recommendation(forRegion region: Region? = nil) -> [RetryableHost] {
3839
let regionComponent = region.flatMap { ".\($0.rawValue)" } ?? ""
3940
return [.init(url: URL(string: "recommendation\(regionComponent).algolia.com")!)]
4041
}
4142

43+
public static func personalization(forRegion region: Region? = nil) -> [RetryableHost] {
44+
let regionComponent = region.flatMap { ".\($0.rawValue)" } ?? ""
45+
return [.init(url: URL(string: "personalization\(regionComponent).algolia.com")!)]
46+
}
47+
4248
public static var analytics: [RetryableHost] = [
4349
.init(url: URL(string: "analytics.algolia.com")!)
4450
]

Sources/AlgoliaSearchClient/Models/Personalization/PersonalizationConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct PersonalizationConfiguration: Configuration, Credentials {
3838
self.writeTimeout = writeTimeout
3939
self.readTimeout = readTimeout
4040
self.logLevel = logLevel
41-
self.hosts = Hosts.recommendation(forRegion: region)
41+
self.hosts = Hosts.personalization(forRegion: region)
4242
self.defaultHeaders = defaultHeaders
4343
self.batchSize = batchSize
4444
}

0 commit comments

Comments
 (0)