Class: Zendesk2::CreateHelpCenterTopic

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/zendesk2/help_center/create_help_center_topic.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_topic.rb', line 9

def self.accepted_attributes
  %w(name position description)
end

Instance Method Details

#mockObject



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

def mock
  identity = cistern.serial_id

  position = data[:help_center_topics].size

  record = {
    'id'          => identity,
    'url'         => url_for("/communit/topics/#{identity}.json"),
    'html_url'    => html_url_for("/hc/topics/#{identity}.json"),
    'position'    => position,
    'created_at'  => timestamp,
    'updated_at'  => timestamp,
    'description' => '',
  }.merge(topic_params)

  data[:help_center_topics][identity] = record

  mock_response('topic' => record)
end

#topic_paramsObject



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

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