lib/zendesk2/client/collections/tickets.rb in zendesk2-1.5.6 vs lib/zendesk2/client/collections/tickets.rb in zendesk2-1.5.7

- old
+ new

@@ -2,11 +2,29 @@ include Zendesk2::PagedCollection include Zendesk2::Searchable model Zendesk2::Client::Ticket - self.collection_method = :get_tickets + attribute :requester_id + attribute :collaborator_id + self.collection_root = "tickets" self.model_method = :get_ticket self.model_root = "ticket" self.search_type = "ticket" + + def collection_page(params={}) + collection_method = if requester_id + :get_requested_tickets + elsif collaborator_id + :get_ccd_tickets + else + :get_tickets + end + + body = service.send(collection_method, Cistern::Hash.stringify_keys(self.attributes.merge(params))).body + + self.load(body[collection_root]) # 'results' is the key for paged seraches + self.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page")) + self + end end