switch self { case .Items(let page, let perPage, let query): let searchQueries: [String] = query.flatMap { $0.toString() } let searchQueryString = searchQueries.reduce("") { $0 == "" ? $1 : $0 + "+" + $1 } let parameters = [ URLQueryParameter(name: "page", value: page), URLQueryParameter(name: "per_page", value: perPage), URLQueryParameter(name: "query", value: searchQueryString, needsEncode: false) ] return convertParametersToString(parameters) } } private func convertParametersToString(queries: [URLQueryParameter?]) -> String { let queries: [String] = queries.flatMap { $0?.toPrameterString } let queryString: String = queries.reduce("") { $0 == "" ? $1 : $0 + "&" + $1 } return queryString } }