@@ -63,8 +63,8 @@ public class Client {
6363 }
6464
6565 public let appID : String
66- public let hostnames : [ String ]
6766
67+ private var hostnames : [ String ]
6868 private let manager : Manager
6969 private var requestBuffer = RingBuffer < Request > ( maxCapacity: 10 )
7070
@@ -78,9 +78,9 @@ public class Client {
7878 /// :param: tagFilters value of the header X-Algolia-TagFilters
7979 /// :param: userToken value of the header X-Algolia-UserToken
8080 public init ( appID: String , apiKey: String , hostnames: [ String ] ? = nil , dsn: Bool = false , dsnHost: String ? = nil , tagFilters: String ? = nil , userToken: String ? = nil ) {
81- if countElements ( appID) == 0 {
81+ if count ( appID) == 0 {
8282 NSException ( name: " InvalidArgument " , reason: " Application ID must be set " , userInfo: nil ) . raise ( )
83- } else if countElements ( apiKey) == 0 {
83+ } else if count ( apiKey) == 0 {
8484 NSException ( name: " InvalidArgument " , reason: " APIKey must be set " , userInfo: nil ) . raise ( )
8585 }
8686
@@ -108,7 +108,7 @@ public class Client {
108108 }
109109 }
110110
111- let version = NSBundle ( identifier: " com.algolia.AlgoliaSearch " ) !. infoDictionary![ " CFBundleShortVersionString " ] as String
111+ let version = NSBundle ( identifier: " com.algolia.AlgoliaSearch " ) !. infoDictionary![ " CFBundleShortVersionString " ] as! String
112112 var HTTPHeaders = [
113113 " X-Algolia-API-Key " : self . apiKey,
114114 " X-Algolia-Application-Id " : self . appID,
@@ -336,8 +336,8 @@ public class Client {
336336 for query in queries {
337337 if let query = query as? [ String : AnyObject ] {
338338 convertedQueries. append ( [
339- " params " : ( query [ " query " ] as Query ) . buildURL ( ) ,
340- " indexName " : query [ " indexName " ] as String
339+ " params " : ( query [ " query " ] as! Query ) . buildURL ( ) ,
340+ " indexName " : query [ " indexName " ] as! String
341341 ] )
342342 }
343343 }
@@ -357,16 +357,16 @@ public class Client {
357357 if let block = block {
358358 switch ( statusCode) {
359359 case 200 , 201 :
360- block ( JSON: ( data as [ String : AnyObject ] ) , error: nil )
360+ block ( JSON: ( data as! [ String : AnyObject ] ) , error: nil )
361361 case 400 :
362- let errorMessage = data![ " message " ] as String
362+ let errorMessage = data![ " message " ] as! String
363363 block ( JSON: nil , error: NSError ( domain: " Bad request argument: \( errorMessage) " , code: 400 , userInfo: nil ) )
364364 case 403 :
365365 block ( JSON: nil , error: NSError ( domain: " Invalid Application-ID or API-Key " , code: 403 , userInfo: nil ) )
366366 case 404 :
367367 block ( JSON: nil , error: NSError ( domain: " Resource does not exist " , code: 404 , userInfo: nil ) )
368368 default :
369- if let errorMessage = ( data as [ String : String ] ) [ " message " ] {
369+ if let errorMessage = ( data as! [ String : String ] ) [ " message " ] {
370370 block ( JSON: nil , error: NSError ( domain: errorMessage, code: 0 , userInfo: nil ) )
371371 } else {
372372 block ( JSON: nil , error: NSError ( domain: " No error message " , code: 0 , userInfo: nil ) )
@@ -388,7 +388,7 @@ public class Client {
388388 /// Cancel a queries. Only the last ten queries can be cancelled.
389389 func cancelQueries( method: HTTPMethod , path: String ) {
390390 for request in requestBuffer {
391- if request. request. URL. path == path {
391+ if request. request. URL! . path! == path {
392392 if request. request. HTTPMethod == method. rawValue {
393393 request. cancel ( )
394394 }
0 commit comments