Sha256: a5c282084ac5c5b15e2dbd89cda423592a4f7cc5b1660b7c1ef04e0cb9a67556

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

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

  request_method :post
  request_path { |_| '/categories.json' }
  request_body { |r| { 'category' => r.params['category'] } }

  def self.accepted_attributes
    %w(id name description position)
  end

  def mock
    identity = cistern.serial_id

    record = {
      'id'         => identity,
      'url'        => url_for("/categories/#{identity}.json"),
      'created_at' => timestamp,
      'updated_at' => timestamp,
    }.merge(Cistern::Hash.slice(params.fetch('category'), *self.class.accepted_attributes))

    cistern.data[:categories][identity] = record

    mock_response({ 'category' => record }, { status: 201 })
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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