Sha256: ce201add7ef95979f7d07be2e63a720b6e8fe956a8b24fdbb571d51c1b2db2f9

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

class Zendesk2::Client::Tickets < Zendesk2::Client::Collection
  include Zendesk2::PagedCollection
  include Zendesk2::Searchable
  extend Zendesk2::Attributes

  model Zendesk2::Client::Ticket

  attribute :requester_id, type: :integer
  attribute :collaborator_id, type: :integer

  assoc_accessor :requester
  assoc_accessor :collaborator

  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 searches
    self.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
    self
  end

  scopes << :requester_id
  scopes << :collaborator_id
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zendesk2-1.6.1 lib/zendesk2/client/collections/tickets.rb
zendesk2-1.5.17 lib/zendesk2/client/collections/tickets.rb
zendesk2-1.5.16 lib/zendesk2/client/collections/tickets.rb
zendesk2-1.5.15 lib/zendesk2/client/collections/tickets.rb
zendesk2-1.5.14 lib/zendesk2/client/collections/tickets.rb
zendesk2-1.5.13 lib/zendesk2/client/collections/tickets.rb