Skip to content

Commit c1be4fb

Browse files
fix(longAPIKey): Move API key to body if the key's length > 500 chars (#769)
* fix URL construction compatibility with previous Swift versions * dispatch long api keys to request body
1 parent 3ebf7b1 commit c1be4fb

File tree

13 files changed

+115
-26
lines changed

13 files changed

+115
-26
lines changed

Sources/AlgoliaSearchClient/Command/Command+ABTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension Command {
1515

1616
let method: HTTPMethod = .post
1717
let callType: CallType = .write
18-
let path: URL = .ABTestsV2
18+
let path = URL.ABTestsV2
1919
let body: Data?
2020
let requestOptions: RequestOptions?
2121

@@ -79,7 +79,7 @@ extension Command {
7979

8080
let method: HTTPMethod = .get
8181
let callType: CallType = .read
82-
let path: URL = .ABTestsV2
82+
let path = URL.ABTestsV2
8383
let requestOptions: RequestOptions?
8484

8585
init(offset: Int?, limit: Int?, requestOptions: RequestOptions?) {

Sources/AlgoliaSearchClient/Command/Command+APIKeys.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension Command {
1515

1616
let method: HTTPMethod = .post
1717
let callType: CallType = .write
18-
let path: URL = .keysV1
18+
let path = URL.keysV1
1919
let body: Data?
2020
let requestOptions: RequestOptions?
2121

@@ -97,7 +97,7 @@ extension Command {
9797

9898
let method: HTTPMethod = .get
9999
let callType: CallType = .read
100-
let path: URL = .keysV1
100+
let path = URL.keysV1
101101
let requestOptions: RequestOptions?
102102

103103
init(requestOptions: RequestOptions?) {

Sources/AlgoliaSearchClient/Command/Command+Advanced.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension Command {
4949

5050
let method: HTTPMethod = .get
5151
let callType: CallType = .read
52-
let path: URL = .logs
52+
let path = URL.logs
5353
let requestOptions: RequestOptions?
5454

5555
init(indexName: IndexName?, offset: Int?, length: Int?, logType: LogType, requestOptions: RequestOptions?) {

Sources/AlgoliaSearchClient/Command/Command+Insights.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension Command {
1515

1616
let method: HTTPMethod = .post
1717
let callType: CallType = .write
18-
let path: URL = .eventsV1
18+
let path = URL.eventsV1
1919
let body: Data?
2020
let requestOptions: RequestOptions?
2121

Sources/AlgoliaSearchClient/Command/Command+MultiCluster.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension Command {
1515

1616
let method: HTTPMethod = .get
1717
let callType: CallType = .read
18-
let path: URL = .clustersV1
18+
let path = URL.clustersV1
1919
let requestOptions: RequestOptions?
2020

2121
init(requestOptions: RequestOptions?) {
@@ -53,7 +53,7 @@ extension Command.MultiCluster {
5353

5454
let method: HTTPMethod = .post
5555
let callType: CallType = .write
56-
let path: URL = .clustersV1.appending(.mapping)
56+
let path = URL.clustersV1.appending(.mapping)
5757
let body: Data?
5858
let requestOptions: RequestOptions?
5959

@@ -105,7 +105,7 @@ extension Command.MultiCluster {
105105

106106
let method: HTTPMethod = .get
107107
let callType: CallType = .read
108-
let path: URL = .clustersV1
108+
let path = URL.clustersV1
109109
.appending(.mapping)
110110
.appending(.top)
111111
let requestOptions: RequestOptions?
@@ -120,7 +120,7 @@ extension Command.MultiCluster {
120120

121121
let method: HTTPMethod = .get
122122
let callType: CallType = .read
123-
let path: URL = .clustersV1
123+
let path = URL.clustersV1
124124
.appending(.mapping)
125125
let requestOptions: RequestOptions?
126126

@@ -155,7 +155,7 @@ extension Command.MultiCluster {
155155

156156
let method: HTTPMethod = .post
157157
let callType: CallType = .read
158-
let path: URL = .clustersV1
158+
let path = URL.clustersV1
159159
.appending(.mapping)
160160
.appending(.search)
161161
let body: Data?

Sources/AlgoliaSearchClient/Command/Command+MultipleIndex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension Command {
1515

1616
let method: HTTPMethod = .get
1717
let callType: CallType = .read
18-
let path: URL = .indexesV1
18+
let path = URL.indexesV1
1919
let requestOptions: RequestOptions?
2020

2121
init(requestOptions: RequestOptions?) {

Sources/AlgoliaSearchClient/Command/Command+Personalization.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension Command {
1515

1616
let method: HTTPMethod = .get
1717
let callType: CallType = .read
18-
let path: URL = .strategies.appending(.personalization)
18+
let path = URL.strategies.appending(.personalization)
1919
let requestOptions: RequestOptions?
2020

2121
init(requestOptions: RequestOptions?) {
@@ -28,7 +28,7 @@ extension Command {
2828

2929
let method: HTTPMethod = .post
3030
let callType: CallType = .write
31-
let path: URL = .strategies.appending(.personalization)
31+
let path = URL.strategies.appending(.personalization)
3232
let body: Data?
3333
let requestOptions: RequestOptions?
3434

Sources/AlgoliaSearchClient/Command/Command.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension Command {
1414
struct Template: AlgoliaCommand {
1515
var method: HTTPMethod = .get
1616
let callType: CallType = .read
17-
let path: URL = .indexesV1
17+
let path = URL.indexesV1
1818
let body: Data?
1919
let requestOptions: RequestOptions? = nil
2020
}

Sources/AlgoliaSearchClient/Helpers/UserAgent/UserAgent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ extension UserAgent: CustomStringConvertible {
3434
}
3535

3636
extension UserAgent: UserAgentExtending {
37-
37+
3838
public var userAgentExtension: String {
3939
return description
4040
}
41-
41+
4242
}
4343

4444
extension UserAgent {

Sources/AlgoliaSearchClient/Helpers/UserAgent/UserAgentController.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public struct UserAgentController {
1212
public static var userAgents: [UserAgent] {
1313
extensions.compactMap { $0 as? UserAgent }
1414
}
15-
15+
1616
public internal(set) static var extensions: [UserAgentExtending] = [UserAgent.operatingSystem, UserAgent.library]
17-
17+
1818
public static var httpHeaderValue: String {
1919
return extensions.map(\.userAgentExtension).joined(separator: "; ")
2020
}
@@ -24,7 +24,7 @@ public struct UserAgentController {
2424
public static func append(userAgent: UserAgent) {
2525
extensions.append(userAgent)
2626
}
27-
27+
2828
/// Append user agent to include into each API call.
2929
public static func append(_ userAgentExtension: UserAgentExtending) {
3030
extensions.append(userAgentExtension)
@@ -33,8 +33,7 @@ public struct UserAgentController {
3333
}
3434

3535
public protocol UserAgentExtending {
36-
36+
3737
var userAgentExtension: String { get }
38-
39-
}
4038

39+
}

0 commit comments

Comments
 (0)