Sha256: 77d68ab9f4e6dbcd58d39b0c0335972cbd987cc4f910eff098c42a59c6557def

Contents?: true

Size: 927 Bytes

Versions: 21

Compression:

Stored size: 927 Bytes

Contents

class Zendesk2::Client::CreateTopicComment < Zendesk2::Client::Request
  request_method :post
  request_path { |r| "/topics/#{r.topic_id}/comments.json" }
  request_body { |r| { "topic_comment" => r.topic_comment_params } }

  def self.accepted_attributes
    %w[user_id body informative]
  end

  def topic_id
    params.fetch("topic_comment").fetch("topic_id").to_i
  end

  def topic_comment_params
    Cistern::Hash.slice(params.fetch("topic_comment"), *self.class.accepted_attributes)
  end

  def mock
    identity = service.serial_id

    record = {
      "id"         => identity,
      "url"        => url_for("/topics/#{topic_id}/comments/#{identity}.json"),
      "created_at" => Time.now.iso8601,
      "updated_at" => Time.now.iso8601,
      "topic_id"   => self.topic_id,
    }.merge(topic_comment_params)

    self.data[:topic_comments][identity] = record

    mock_response("topic_comment" => record)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zendesk2-1.7.5 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.7.4 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.7.2 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.7.1 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.7.0 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.6.1 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.17 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.16 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.15 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.14 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.13 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.12 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.11 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.10 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.9 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.8 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.7 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.6 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.5 lib/zendesk2/client/requests/create_topic_comment.rb
zendesk2-1.5.4 lib/zendesk2/client/requests/create_topic_comment.rb