Skip to content

Commit 84a93ae

Browse files
author
Clément Le Provost
committed
Merge branch 'hotfix/paths' of https://github.com/alexfish/algoliasearch-client-swift into alexfish-hotfix/paths
2 parents 24ce0d3 + ee65207 commit 84a93ae

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

Source/Client.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ public class Client : NSObject {
158158
///
159159
/// :return: JSON Object in the handler in the form: { "items": [ {"name": "contacts", "createdAt": "2013-01-18T15:33:13.556Z"}, {"name": "notes", "createdAt": "2013-01-18T15:33:13.556Z"}]}
160160
public func listIndexes(block: CompletionHandler) {
161-
performHTTPQuery("1/indexes", method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
161+
performHTTPQuery("/1/indexes", method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
162162
}
163163

164164
/// Delete an index.
165165
///
166166
/// - parameter indexName: the name of index to delete
167167
/// :return: JSON Object in the handler containing a "deletedAt" attribute
168168
public func deleteIndex(indexName: String, block: CompletionHandler? = nil) {
169-
let path = "1/indexes/\(indexName.urlEncode())"
169+
let path = "/1/indexes/\(indexName.urlEncode())"
170170
performHTTPQuery(path, method: .DELETE, body: nil, hostnames: writeQueryHostnames, block: block)
171171
}
172172

@@ -175,7 +175,7 @@ public class Client : NSObject {
175175
/// - parameter srcIndexName: the name of index to move.
176176
/// - parameter dstIndexName: the new index name that will contains sourceIndexName (destination will be overriten if it already exist).
177177
public func moveIndex(srcIndexName: String, to dstIndexName: String, block: CompletionHandler? = nil) {
178-
let path = "1/indexes/\(srcIndexName.urlEncode())/operation"
178+
let path = "/1/indexes/\(srcIndexName.urlEncode())/operation"
179179
let request = [
180180
"destination": dstIndexName,
181181
"operation": "move"
@@ -189,7 +189,7 @@ public class Client : NSObject {
189189
/// - parameter srcIndexName: the name of index to copy.
190190
/// - parameter dstIndexName: the new index name that will contains a copy of sourceIndexName (destination will be overriten if it already exist).
191191
public func copyIndex(srcIndexName: String, to dstIndexName: String, block: CompletionHandler? = nil) {
192-
let path = "1/indexes/\(srcIndexName.urlEncode())/operation"
192+
let path = "/1/indexes/\(srcIndexName.urlEncode())/operation"
193193
let request = [
194194
"destination": dstIndexName,
195195
"operation": "copy"
@@ -200,15 +200,15 @@ public class Client : NSObject {
200200

201201
/// Return 10 last log entries.
202202
public func getLogs(block: CompletionHandler) {
203-
performHTTPQuery("1/logs", method: .GET, body: nil, hostnames: writeQueryHostnames, block: block)
203+
performHTTPQuery("/1/logs", method: .GET, body: nil, hostnames: writeQueryHostnames, block: block)
204204
}
205205

206206
/// Return last logs entries.
207207
///
208208
/// - parameter offset: Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
209209
/// - parameter length: Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
210210
public func getLogsWithOffset(offset: UInt, length: UInt, block: CompletionHandler) {
211-
let path = "1/logs?offset=\(offset)&length=\(length)"
211+
let path = "/1/logs?offset=\(offset)&length=\(length)"
212212
performHTTPQuery(path, method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
213213
}
214214

@@ -217,7 +217,7 @@ public class Client : NSObject {
217217
/// - parameter offset: Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
218218
/// - parameter length: Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
219219
public func getLogsWithType(type: String, offset: UInt, length: UInt, block: CompletionHandler) {
220-
let path = "1/logs?offset=\(offset)&length=\(length)&type=\(type)"
220+
let path = "/1/logs?offset=\(offset)&length=\(length)&type=\(type)"
221221
performHTTPQuery(path, method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
222222
}
223223

@@ -230,18 +230,18 @@ public class Client : NSObject {
230230

231231
/// List all existing user keys with their associated ACLs.
232232
public func listUserKeys(block: CompletionHandler) {
233-
performHTTPQuery("1/keys", method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
233+
performHTTPQuery("/1/keys", method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
234234
}
235235

236236
/// Get ACL of a user key.
237237
public func getUserKeyACL(key: String, block: CompletionHandler) {
238-
let path = "1/keys/\(key)"
238+
let path = "/1/keys/\(key)"
239239
performHTTPQuery(path, method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
240240
}
241241

242242
/// Delete an existing user key.
243243
public func deleteUserKey(key: String, block: CompletionHandler? = nil) {
244-
let path = "1/keys/\(key)"
244+
let path = "/1/keys/\(key)"
245245
performHTTPQuery(path, method: .DELETE, body: nil, hostnames: writeQueryHostnames, block: block)
246246
}
247247

@@ -250,7 +250,7 @@ public class Client : NSObject {
250250
/// - parameter acls: The list of ACL for this key. The list can contains the following values (as String): search, addObject, deleteObject, deleteIndex, settings, editSettings
251251
public func addUserKey(acls: [String], block: CompletionHandler? = nil) {
252252
let request = ["acl": acls]
253-
performHTTPQuery("1/keys", method: .POST, body: request, hostnames: writeQueryHostnames, block: block)
253+
performHTTPQuery("/1/keys", method: .POST, body: request, hostnames: writeQueryHostnames, block: block)
254254
}
255255

256256
/// Create a new user key
@@ -267,7 +267,7 @@ public class Client : NSObject {
267267
"maxHitsPerQuery": maxHits,
268268
]
269269

270-
performHTTPQuery("1/keys", method: .POST, body: request, hostnames: writeQueryHostnames, block: block)
270+
performHTTPQuery("/1/keys", method: .POST, body: request, hostnames: writeQueryHostnames, block: block)
271271
}
272272

273273
/// Create a new user key
@@ -286,15 +286,15 @@ public class Client : NSObject {
286286
"maxHitsPerQuery": maxHits,
287287
]
288288

289-
performHTTPQuery("1/keys", method: .POST, body: request, hostnames: writeQueryHostnames, block: block)
289+
performHTTPQuery("/1/keys", method: .POST, body: request, hostnames: writeQueryHostnames, block: block)
290290
}
291291

292292
/// Update a user key
293293
///
294294
/// - parameter key: The key to update
295295
/// - parameter withAcls: The list of ACL for this key. The list can contains the following values (as String): search, addObject, deleteObject, deleteIndex, settings, editSettings
296296
public func updateUserKey(key: String, withACL acls: [String], block: CompletionHandler? = nil) {
297-
let path = "1/keys/\(key)"
297+
let path = "/1/keys/\(key)"
298298
let request = ["acl": acls]
299299
performHTTPQuery(path, method: .PUT, body: request, hostnames: writeQueryHostnames, block: block)
300300
}
@@ -307,7 +307,7 @@ public class Client : NSObject {
307307
/// - parameter maxQueriesPerIPPerHour: Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (unlimited).
308308
/// - parameter maxHitsPerQuery: Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
309309
public func updateUserKey(key: String, withACL acls: [String], andValidity validity: UInt, maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandler? = nil) {
310-
let path = "1/keys/\(key)"
310+
let path = "/1/keys/\(key)"
311311
let request: [String: AnyObject] = [
312312
"acl": acls,
313313
"validity": validity,
@@ -327,7 +327,7 @@ public class Client : NSObject {
327327
/// - parameter maxQueriesPerIPPerHour: Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (unlimited).
328328
/// - parameter maxHitsPerQuery: Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
329329
public func updateUserKey(key: String, withACL acls: [String], andValidity validity: UInt, forIndexes indexes: [String], maxQueriesPerIPPerHour maxQueries: UInt, maxHitsPerQuery maxHits: UInt, block: CompletionHandler? = nil) {
330-
let path = "1/keys/\(key)"
330+
let path = "/1/keys/\(key)"
331331
let request: [String: AnyObject] = [
332332
"acl": acls,
333333
"indexes": indexes,
@@ -343,7 +343,7 @@ public class Client : NSObject {
343343
///
344344
/// - parameter queries: An array of queries with the associated index (Array of Dictionnary object ["indexName": "targettedIndex", "query": QueryObject]).
345345
public func multipleQueries(queries: [AnyObject], block: CompletionHandler? = nil) {
346-
let path = "1/indexes/*/queries"
346+
let path = "/1/indexes/*/queries"
347347

348348
var convertedQueries = [[String: String]]()
349349
convertedQueries.reserveCapacity(queries.count)
@@ -372,7 +372,7 @@ public class Client : NSObject {
372372
}
373373
manager.session.configuration.timeoutIntervalForRequest = currentTimeout
374374

375-
let request = manager.request(method, "https://\(hostnames[index])/\(path)", HTTPHeaders: httpHeaders, parameters: body) { (response, data, error) -> Void in
375+
let request = manager.request(method, "https://\(hostnames[index] + path)", HTTPHeaders: httpHeaders, parameters: body) { (response, data, error) -> Void in
376376
if let statusCode = response?.statusCode {
377377
if let block = block {
378378
switch(statusCode) {

0 commit comments

Comments
 (0)