Class: Zendesk2::Tickets

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Includes:
Collection, PagedCollection, Searchable
Defined in:
lib/zendesk2/tickets.rb

Instance Method Summary collapse

Methods included from Attributes

assoc_accessor, assoc_reader, assoc_writer

Methods included from Searchable

included, #search

Methods included from PagedCollection

#all, #all_entries, #collection_method, #collection_root, #create, #create!, #each_entry, #each_page, #get, #get!, included, #model_method, #model_root, #new_page, #next_page, #previous_page

Methods included from Collection

#all, cistern_included, #collection_method, #collection_root, #create, #create!, #get, #get!, included, #model_method, #model_root, #namespace, #new

Instance Method Details

#collection_page(params = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/zendesk2/tickets.rb', line 23

def collection_page(params = {})
  collection_method = if requester_id
                        :get_requested_tickets
                      elsif collaborator_id
                        :get_ccd_tickets
                      elsif view_id
                        :get_view_tickets
                      else
                        :get_tickets
                      end

  body = cistern.send(collection_method, Cistern::Hash.stringify_keys(attributes.merge(params))).body

  load(body[collection_root]) # 'results' is the key for paged searches
  merge_attributes(Cistern::Hash.slice(body, 'count', 'next_page', 'previous_page'))
  self
end