Sha256: 4120847bd2ab396886f94e8e352032dc7585a35b02004ecaa594366a4a6e1b4f

Contents?: true

Size: 936 Bytes

Versions: 4

Compression:

Stored size: 936 Bytes

Contents

class Zendesk2::Client::TopicComments < Zendesk2::Collection
  include Zendesk2::PagedCollection
  include Zendesk2::Searchable

  attribute :topic_id

  model Zendesk2::Client::TopicComment

  self.collection_method = :get_topic_comments
  self.collection_root   = "topic_comments"
  self.model_method      = :get_topic_comment
  self.model_root        = "topic_comment"
  self.search_type       = "topic_comment"

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk2-0.1.0 lib/zendesk2/client/models/topic_comments.rb
zendesk2-0.0.23 lib/zendesk2/client/models/topic_comments.rb
zendesk2-0.0.22 lib/zendesk2/client/models/topic_comments.rb
zendesk2-0.0.20 lib/zendesk2/client/models/topic_comments.rb