Class: Zendesk2::CreateHelpCenterSection
- Inherits:
-
Object
- Object
- Zendesk2::CreateHelpCenterSection
- Includes:
- Request
- Defined in:
- lib/zendesk2/help_center/create_help_center_section.rb
Instance Attribute Summary
Attributes included from Request
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Request
#call, cistern_included, #data, #delete!, #error!, #find!, #html_url_for, included, #mock_response, #page, #page_params!, #page_params?, #pluralize, #real, #real_request, #request_body, #request_params, #request_path, #resources, #response, #timestamp, #url_for
Class Method Details
.accepted_attributes ⇒ Object
9 10 11 |
# 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 |
Instance Method Details
#category_id ⇒ Object
17 18 19 |
# File 'lib/zendesk2/help_center/create_help_center_section.rb', line 17 def category_id params.fetch('section').fetch('category_id') end |
#mock ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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' => , 'updated_at' => , '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 ⇒ Object
13 14 15 |
# 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 |