Class: Zendesk2::CreateHelpCenterArticle
- Inherits:
-
Object
- Object
- Zendesk2::CreateHelpCenterArticle
show all
- Includes:
- Request
- Defined in:
- lib/zendesk2/help_center/create_help_center_article.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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/zendesk2/help_center/create_help_center_article.rb', line 16
def self.accepted_attributes
%w(
author_id
body
comments_disabled
draft
label_names
locale
position
promoted
section_id
title user_segment_id
permission_group_id
)
end
|
Instance Method Details
#article_params ⇒ Object
32
33
34
|
# File 'lib/zendesk2/help_center/create_help_center_article.rb', line 32
def article_params
@_article_params ||= Cistern::Hash.slice(params.fetch('article'), *self.class.accepted_attributes)
end
|
#mock ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/zendesk2/help_center/create_help_center_article.rb', line 40
def mock
identity = cistern.serial_id
locale = params['locale'] ||= 'en-us'
position = data[:help_center_articles].values.select { |a| a['section_id'] == section_id }.size
record = {
'id' => identity,
'url' => url_for("/help_center/#{locale}/articles/#{identity}.json"),
'html_url' => html_url_for("/hc/#{locale}/articles/#{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,
'section_id' => section_id,
'created_at' => timestamp,
'updated_at' => timestamp,
'title' => '',
'body' => '',
'source_locale' => locale,
'outdated' => false,
'user_segment_id' => 0,
'permission_group_id' => 0,
}.merge(article_params)
data[:help_center_articles][identity] = record
mock_response('article' => record)
end
|
#section_id ⇒ Object
36
37
38
|
# File 'lib/zendesk2/help_center/create_help_center_article.rb', line 36
def section_id
params.fetch('article').fetch('section_id')
end
|