Skip to content

Commit

Permalink
Bump to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dethi committed Jun 8, 2015
1 parent 53fa726 commit 5ac0671
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CHANGELOG

2015-05-04 1.2.0
2015-06-08 1.2.0
* new retry logic
* add new parameter on the Query: setMinProximity & setHighlightingTags
* add new method on the Query: resetLocationParameters
38 changes: 22 additions & 16 deletions Source/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public class Client {
/// :param: apiKey a valid API key for the service
/// :param: tagFilters value of the header X-Algolia-TagFilters
/// :param: userToken value of the header X-Algolia-UserToken
public init(appID: String, apiKey: String, tagFilters: String? = nil, userToken: String? = nil) {
/// :param: hostnames the list of hosts that you have received for the service
public init(appID: String, apiKey: String, tagFilters: String? = nil, userToken: String? = nil, hostnames: [String]? = nil) {
if count(appID) == 0 {
NSException(name: "InvalidArgument", reason: "Application ID must be set", userInfo: nil).raise()
} else if count(apiKey) == 0 {
Expand All @@ -86,20 +87,25 @@ public class Client {
self.tagFilters = tagFilters
self.userToken = userToken

readQueryHostnames = [
"\(appID)-DSN.algolia.net",
"\(appID)-1.algolianet.com",
"\(appID)-2.algolianet.com",
"\(appID)-3.algolianet.com"
]

writeQueryHostnames = [
"\(appID).algolia.net",
"\(appID)-1.algolianet.com",
"\(appID)-2.algolianet.com",
"\(appID)-3.algolianet.com"
]

if let hostnames = hostnames {
readQueryHostnames = hostnames
writeQueryHostnames = hostnames
} else {
readQueryHostnames = [
"\(appID)-DSN.algolia.net",
"\(appID)-1.algolianet.com",
"\(appID)-2.algolianet.com",
"\(appID)-3.algolianet.com"
]

writeQueryHostnames = [
"\(appID).algolia.net",
"\(appID)-1.algolianet.com",
"\(appID)-2.algolianet.com",
"\(appID)-3.algolianet.com"
]
}

let version = NSBundle(forClass: self.dynamicType).infoDictionary!["CFBundleShortVersionString"] as! String

var HTTPHeaders = [
Expand Down Expand Up @@ -179,7 +185,7 @@ public class Client {

/// Return 10 last log entries.
public func getLogs(block: CompletionHandler) {
performHTTPQuery("1/logs", method: .GET, body: nil, hostnames: readQueryHostnames, block: block)
performHTTPQuery("1/logs", method: .GET, body: nil, hostnames: writeQueryHostnames, block: block)
}

/// Return last logs entries.
Expand Down
10 changes: 0 additions & 10 deletions Source/Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@

import Foundation

extension Array {
/// Shuffle the array
mutating func shuffle() {
for i in 0..<(count - 1) {
let j = Int(arc4random_uniform(UInt32(count - i))) + i
swap(&self[i], &self[j])
}
}
}

extension String {
/// Return URL encoded version of the string
func urlEncode() -> String {
Expand Down

0 comments on commit 5ac0671

Please sign in to comment.