 // Heavily inspired by Alamofire ParameterEncoding
 // https://github.com/Alamofire/Alamofire/blob/master/Source/ParameterEncoding.swift
 
+enum ParameterEncodingError: ErrorProtocol {
+  case CouldNotCreateComponentsFromURL
+  case CouldNotCreateURLFromComponents
+}
+
 enum ParameterEncoding {
   case URL
   case JSON

      throw RequestError.NotImplemented
    }
  }
}
    }
    
    switch self {
    case .URL:
      guard let components = NSURLComponents(url: request.url!, resolvingAgainstBaseURL: false) else {
        throw ParameterEncodingError.CouldNotCreateComponentsFromURL // this should never happen
      }
      components.query = NSDictionary(dictionary: parameters).toQueryString()
      
      guard let newURL = components.url else {
        throw ParameterEncodingError.CouldNotCreateComponentsFromURL // this should never happen
      }
      request.url = newURL
      
    case .JSON:
      let options = NSJSONWritingOptions()
      let data = try NSJSONSerialization.data(withJSONObject: parameters, options: options)
