Class: Zendesk2::CreateHelpCenterPost

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/zendesk2/help_center/create_help_center_post.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_attributesObject



9
10
11
# File 'lib/zendesk2/help_center/create_help_center_post.rb', line 9

def self.accepted_attributes
  %w(title details author_id topic_id pinned featured closed status created_at)
end

Instance Method Details

#mockObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/zendesk2/help_center/create_help_center_post.rb', line 17

def mock
  identity = cistern.serial_id

  record = {
    'id'             => identity,
    'url'            => url_for("/community/posts/#{identity}.json"),
    'html_url'       => html_url_for("/hc/posts/#{identity}.json"),
    'created_at'     => timestamp,
    'updated_at'     => timestamp,
    'vote_count'     => 0,
    'vote_sum'       => 0,
    'comment_count'  => 0,
    'follower_count' => 0,
    'details'        => '',
  }.merge(post_params)

  data[:help_center_posts][identity] = record

  mock_response('post' => record)
end

#post_paramsObject



13
14
15
# File 'lib/zendesk2/help_center/create_help_center_post.rb', line 13

def post_params
  Cistern::Hash.slice(params.fetch('post'), *self.class.accepted_attributes)
end