Sha256: 64692b73fdeb00ba8b2501d49c24d7cadda1a1f2b5bf7998e559f89b747c18a0

Contents?: true

Size: 646 Bytes

Versions: 16

Compression:

Stored size: 646 Bytes

Contents

class Zendesk2::Client
  class Real
    def search(query)
      term = query.map{|k,v| "#{k}:#{v}"}.join(" ")
      request(
        :method => :get,
        :params => {query: "\"#{term}\""},
        :path   => "/search.json",
      )
    end
  end # Real

  class Mock
    def search(query)
      type       = query.delete("type")
      collection = type.nil? ? self.data.values : self.data[pluralize(type).to_sym]

      results = collection.select{|k,v| query.all?{|term, condition| v[term.to_s] == condition}}.values

      response(
        :path => "/search.json",
        :body => {"results" => results},
      )
    end
  end # Mock
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
zendesk2-0.2.2 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.1 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.0 lib/zendesk2/client/requests/search.rb
zendesk2-0.1.3 lib/zendesk2/client/requests/search.rb
zendesk2-0.1.2 lib/zendesk2/client/requests/search.rb
zendesk2-0.1.1 lib/zendesk2/client/requests/search.rb
zendesk2-0.1.0 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.23 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.22 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.20 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.19 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.18 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.17 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.16 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.15 lib/zendesk2/client/requests/search.rb
zendesk2-0.0.14 lib/zendesk2/client/requests/search.rb