Sha256: 677c5e2f8bef4ee8c5155743f6951e944294a91c8618f7fad6b32714f6d27b3e

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true
class Zendesk2::CreateTopic
  include Zendesk2::Request

  request_method :post
  request_body { |r| { 'topic' => r.topic_params } }
  request_path { |_| '/topics.json' }

  def self.accepted_attributes
    %w(title body submitter_id updater_id forum_id locked pinned highlighted position tags)
  end

  def topic_params
    @_topic_params ||= Cistern::Hash.slice(params.fetch('topic'), *self.class.accepted_attributes)
  end

  def mock
    identity = cistern.serial_id

    record = {
      'id'         => identity,
      'url'        => url_for("/topics/#{identity}.json"),
      'created_at' => timestamp,
      'updated_at' => timestamp,
    }.merge(topic_params)

    data[:topics][identity] = record

    mock_response('topic' => record)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk2-1.15.0 lib/zendesk2/create_topic.rb
zendesk2-1.13.1 lib/zendesk2/create_topic.rb
zendesk2-1.13.0 lib/zendesk2/create_topic.rb
zendesk2-1.12.0 lib/zendesk2/create_topic.rb