Class: Zendesk2::CreateHelpCenterCategory
- Inherits:
-
Object
- Object
- Zendesk2::CreateHelpCenterCategory
show all
- Includes:
- Request
- Defined in:
- lib/zendesk2/help_center/create_help_center_category.rb
Instance Attribute Summary
Attributes included from Request
#params
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_category.rb', line 9
def self.accepted_attributes
%w(category_id description locale name position sorting)
end
|
Instance Method Details
#category_params ⇒ Object
13
14
15
|
# File 'lib/zendesk2/help_center/create_help_center_category.rb', line 13
def category_params
Cistern::Hash.slice(params.fetch('category'), *self.class.accepted_attributes)
end
|
#mock ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/zendesk2/help_center/create_help_center_category.rb', line 17
def mock
identity = cistern.serial_id
locale = params['locale'] ||= 'en-us'
position = 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' => cistern.current_user['id'],
'position' => position,
'created_at' => timestamp,
'updated_at' => timestamp,
'description' => '',
}.merge(category_params)
data[:help_center_categories][identity] = record
mock_response('category' => record)
end
|