Class: ZendeskAPI::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/zendesk_api/search.rb

Overview

A rich factory that returns a class for your searches

Direct Known Subclasses

SearchExport

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Class Method Details

.model_keyObject



36
37
38
# File 'lib/zendesk_api/search.rb', line 36

def model_key
  "results"
end

.new(client, attributes) ⇒ Object

Quack like a Resource Creates the correct resource class from ‘attributes`



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/zendesk_api/search.rb', line 16

def self.new(client, attributes)
  present_result_type = (attributes[:result_type] || attributes["result_type"]).to_s
  result_type = ZendeskAPI::Helpers.modulize_string(present_result_type)
  klass = begin
            ZendeskAPI.const_get(result_type)
          rescue NameError
            Result
          end

  (klass || Result).new(client, attributes)
end

.resource_nameObject Also known as: resource_path



31
32
33
# File 'lib/zendesk_api/search.rb', line 31

def resource_name
  "search"
end

.search(client, options = {}) ⇒ Object

Creates a search collection



6
7
8
9
10
11
12
# File 'lib/zendesk_api/search.rb', line 6

def self.search(client, options = {})
  if (options.keys.map(&:to_s) & %w[query external_id]).empty?
    warn "you have not specified a query for this search"
  end

  ZendeskAPI::Collection.new(client, self, options)
end