Class: Zendesk2::CreateTopic

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

def self.accepted_attributes
  %w(title body submitter_id updater_id forum_id locked pinned highlighted position tags)
end

Instance Method Details

#mockObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/zendesk2/create_topic.rb', line 17

def mock
  identity = cistern.serial_id

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

  data[:topics][identity] = record

  mock_response('topic' => record)
end

#topic_paramsObject



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

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