Sha256: 122d0d40a05028fa413646ab4cd89e2ea366e40a381c806d17ee30e2f337b1e9
Contents?: true
Size: 824 Bytes
Versions: 19
Compression:
Stored size: 824 Bytes
Contents
class Zendesk2::Client::Search < Zendesk2::Client::Request request_method :get request_body { |r| { query: r.query } } request_path { |_| "/search.json" } page_params! attr_reader :query def _mock(query, params={}) @query = query setup(params) mock end def _real(query, params={}) @query = query setup(params) real end def mock terms = Hash[query.split(" ").map { |t| t.split(":") }] type = terms.delete("type") collection = if type.nil? service.data.values else service.data[pluralize(type).to_sym] end results = collection.values.select { |v| terms.all?{ |term, condition| v[term].to_s == condition.to_s } } page(results, params: {"query" => query}, root: "results") end end
Version data entries
19 entries across 19 versions & 1 rubygems