Class: ZendeskAPI::Search

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

Defined Under Namespace

Classes: Result

Class Method Summary (collapse)

Class Method Details

+ (Object) model_key



185
186
187
# File 'lib/zendesk_api/resources.rb', line 185

def model_key
  "results"
end

+ (Object) new(client, attributes)

Quack like a Resource Creates the correct resource class from the result_type passed in



167
168
169
170
171
172
173
174
175
176
# File 'lib/zendesk_api/resources.rb', line 167

def self.new(client, attributes)
  result_type = attributes["result_type"]

  if result_type
    result_type = ZendeskAPI::Helpers.modulize_string(result_type)
    klass = ZendeskAPI.const_get(result_type) rescue nil
  end

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

+ (Object) resource_name Also known as: resource_path



179
180
181
# File 'lib/zendesk_api/resources.rb', line 179

def resource_name
  "search"
end

+ (Object) search(client, options = {})

Creates a search collection



157
158
159
160
161
162
163
# File 'lib/zendesk_api/resources.rb', line 157

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

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