{ case Stars = "stars" case Forks = "forks" case Updated = "updated" } enum Order: String { case Ascending = "asc" case Descending = "desc" } typealias Response = [Repository] let query: String let sort: Sort let order: Order var URLRequest: NSURLRequest? { return GitHub.URLRequest( method: .GET, path: "/search/repositories", parameters: ["q": query, "sort": sort.rawValue, "order": order.rawValue] ) } init(query: String, sort: Sort = .Stars, order: Order = .Ascending) { self.query = query self.sort = sort self.order = order } func responseFromObject(object: AnyObject) -> Response? { var repositories = [Repository]() if let dictionaries = object["items"] as? [NSDictionary] { for dictionary in dictionaries { if let repository = Repository(dictionary: dictionary) { repositories.append(repository) } } } return repositories } } } initializer Object Mapping