Sha256: 5829660667ac028f6ca0e0741ca13da9f022ef95b470b13d15f50cc0f7893fdb

Contents?: true

Size: 637 Bytes

Versions: 20

Compression:

Stored size: 637 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

20 entries across 20 versions & 1 rubygems

Version Path
zendesk2-1.0.0 lib/zendesk2/client/requests/search.rb
zendesk2-0.5.4 lib/zendesk2/client/requests/search.rb
zendesk2-0.5.3 lib/zendesk2/client/requests/search.rb
zendesk2-0.5.2 lib/zendesk2/client/requests/search.rb
zendesk2-0.5.1 lib/zendesk2/client/requests/search.rb
zendesk2-0.5.0 lib/zendesk2/client/requests/search.rb
zendesk2-0.4.5 lib/zendesk2/client/requests/search.rb
zendesk2-0.4.4 lib/zendesk2/client/requests/search.rb
zendesk2-0.4.3 lib/zendesk2/client/requests/search.rb
zendesk2-0.4.2 lib/zendesk2/client/requests/search.rb
zendesk2-0.4.1 lib/zendesk2/client/requests/search.rb
zendesk2-0.4.0 lib/zendesk2/client/requests/search.rb
zendesk2-0.3.2 lib/zendesk2/client/requests/search.rb
zendesk2-0.3.1 lib/zendesk2/client/requests/search.rb
zendesk2-0.3.0 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.7 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.6 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.5 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.4 lib/zendesk2/client/requests/search.rb
zendesk2-0.2.3 lib/zendesk2/client/requests/search.rb