             } else {
                 return String(character)
             }
-        }.joined().lowercased()
+            }.joined().lowercased()
         return sanitized
     }
     

final class ApiClient {
    
    static let sharedInstance = ApiClient()
    
    private init() {}
    
    func getToken() -> Promise<String> {
        return Promise { fulfill, reject in

    }
    
    func query(input: String, with token: String) -> Promise<([Artist], [Track], [Album])> {
            searchQueue.cancelAllOperations()
            return Promise { fulfill, reject in
                let promiseOp = BlockOperation {
                let artistsResource = self.artistSearchResource(from: input)! //TODO: refactor
                let tracksResource = self.trackSearchResource(from: input)!
                let albumsResource = self.albumSearchResource(from: input)!
                
                when(fulfilled: self.fetch(resource: artistsResource, with: token), self.fetch(resource: tracksResource, with: token), self.fetch(resource: albumsResource, with: token)).then(execute: { (response) -> Void in
                    fulfill(response)
                }).catch(execute: { (error) in
                    reject(error)
                })
            }
            searchQueue.addOperation(promiseOp)
        }
    }
    
