Sha256: 755f903888f1b3846ac026be63d7bdd23d403f10d877da23eb1371eb95d00cf7

Contents?: true

Size: 1.09 KB

Versions: 21

Compression:

Stored size: 1.09 KB

Contents

class Zendesk2::Client::CreateHelpCenterCategory < Zendesk2::Client::Request
  request_method :post
  request_path { |_| "/help_center/categories.json" }
  request_body { |r| {"category" => r.category_params} }

  def self.accepted_attributes
    %w[category_id description locale name position sorting]
  end

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

  def mock
    identity = service.serial_id

    locale = params["locale"] ||= "en-us"
    position = self.data[:help_center_categories].size

    record = {
      "id"          => identity,
      "url"         => url_for("/help_center/#{locale}/categories/#{identity}.json"),
      "html_url"    => html_url_for("/hc/#{locale}/categories/#{identity}.json"),
      "author_id"   => service.current_user["id"],
      "position"    => position,
      "created_at"  => Time.now.iso8601,
      "updated_at"  => Time.now.iso8601,
      "description" => "",
    }.merge(category_params)

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

    mock_response("category" => record)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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