Class: ZendeskAPI::Search
- Inherits:
-
Object
- Object
- ZendeskAPI::Search
- Defined in:
- lib/zendesk_api/search.rb
Overview
A rich factory that returns a class for your searches
Direct Known Subclasses
Defined Under Namespace
Classes: Result
Class Method Summary collapse
- .model_key ⇒ Object
-
.new(client, attributes) ⇒ Object
Quack like a Resource Creates the correct resource class from ‘attributes`.
- .resource_name ⇒ Object (also: resource_path)
-
.search(client, options = {}) ⇒ Object
Creates a search collection.
Class Method Details
.model_key ⇒ Object
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_name ⇒ Object 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, = {}) if (.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, ) end |