 import BothamNetworking
 import CryptoSwift
 
+enum OrderBy: String {
+    case onsaleAscending = "-onsaleDate", onsaleDescending = "onsaleDate"
+}
+
 struct MarvelAPIClient {
 
     static private let baseURL = "http://gateway.marvel.com:80/v1/public/"

        static let timestamp = "ts"
        static let apiKey = "apikey"
        static let hash = "hash"
    }
    
    static func comics(completion:([Comic]) -> ()) {
        
        let apiClient = BothamAPIClient(baseEndpoint: baseURL)
        apiClient.GET(comicsEndPoint, parameters: basicParams()) { result -> () in
            result.mapJSON({ json in
                dispatch_async(dispatch_get_main_queue(), {
                    completion(MarvelAPIParser.parseComics(json))

        let timestamp = NSDate.timeIntervalSinceReferenceDate()
        let hash = "\(timestamp)\(MarvelAPIConfig.privateKey)\(apiKey)".md5()
        
        return [MarvelAPIParams.timestamp: "\(timestamp)",
            MarvelAPIParams.apiKey: apiKey,
            MarvelAPIParams.hash: hash]
    }
}