Class: Zendesk2::HelpCenter::Sections

Inherits:
Object
  • Object
show all
Includes:
Collection, PagedCollection, Searchable
Defined in:
lib/zendesk2/help_center/sections.rb

Instance Method Summary collapse

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



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/zendesk2/help_center/sections.rb', line 19

def collection_page(params = {})
  collection_method = if category_id
                        :get_help_center_categories_sections
                      else
                        :get_help_center_sections
                      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