Sha256: 2825b4a66b4d3bba3bf656b24548c26c8107963b96118556dee9f9abd9c37065

Contents?: true

Size: 919 Bytes

Versions: 26

Compression:

Stored size: 919 Bytes

Contents

class Zendesk2::Client::TicketAudits < Zendesk2::PagedCollection

  model Zendesk2::Client::TicketAudit

  attribute :ticket_id, type: :integer

  self.collection_method = :get_ticket_audits
  self.collection_root   = "audits"
  self.model_method      = :get_ticket_audit
  self.model_root        = "audit"

  def ticket
    self.connection.tickets.get(self.ticket_id)
  end

  def all(params={})
    requires :ticket_id

    body = connection.send(collection_method, {"ticket_id" => self.ticket_id}.merge(params)).body

    collection = self.clone.load(body[collection_root])
    collection.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
    collection
  end

  def get(id)
    requires :ticket_id

    if data = self.connection.send(model_method, {"ticket_id" => self.ticket_id, "id" => id}).body[self.model_root]
      new(data)
    end
  rescue Zendesk2::Error
    nil
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
zendesk2-1.4.2 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.4.1 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.4.0 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.3.3 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.3.2 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.3.1 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.3.0 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.10 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.9 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.7 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.6 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.5 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.4 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.3 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.2 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.1 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.2.0 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.1.3 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.1.2 lib/zendesk2/client/collections/ticket_audits.rb
zendesk2-1.0.0 lib/zendesk2/client/models/ticket_audits.rb