class Zendesk2::CreateHelpCenterSection
Public Class Methods
accepted_attributes()
click to toggle source
# File lib/zendesk2/help_center/create_help_center_section.rb, line 9 def self.accepted_attributes %w(category_id description locale name position sorting) end
Public Instance Methods
category_id()
click to toggle source
# File lib/zendesk2/help_center/create_help_center_section.rb, line 17 def category_id params.fetch('section').fetch('category_id') end
mock()
click to toggle source
# File lib/zendesk2/help_center/create_help_center_section.rb, line 21 def mock identity = cistern.serial_id locale = params['locale'] ||= 'en-us' position = data[:help_center_sections].values.select { |a| a['category_id'] == category_id }.size record = { 'id' => identity, 'url' => url_for("/help_center/#{locale}/sections/#{identity}.json"), 'html_url' => html_url_for("/hc/#{locale}/sections/#{identity}.json"), 'author_id' => cistern.current_user['id'], 'comments_disabled' => false, 'label_names' => [], 'draft' => false, 'promoted' => false, 'position' => position, 'vote_sum' => 0, 'vote_count' => 0, 'category_id' => category_id, 'created_at' => timestamp, 'updated_at' => timestamp, 'name' => '', 'body' => '', 'source_locale' => locale, 'outdated' => false, }.merge(section_params) cistern.data[:help_center_sections][identity] = record access_policy = { 'viewable_by' => 'everyone', 'managable_by' => 'staff', 'restricted_to_group_ids' => [], 'restricted_to_organization_ids' => [], 'required_tags' => [], 'section_id' => identity, } cistern.data[:help_center_access_policies][identity] = access_policy mock_response('section' => record) end
section_params()
click to toggle source
# File lib/zendesk2/help_center/create_help_center_section.rb, line 13 def section_params Cistern::Hash.slice(params.fetch('section'), *self.class.accepted_attributes) end