Class: Zendesk2::CreateTopicComment

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

def self.accepted_attributes
  %w(user_id body informative)
end

Instance Method Details

#mockObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zendesk2/create_topic_comment.rb', line 21

def mock
  identity = cistern.serial_id

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

  data[:topic_comments][identity] = record

  mock_response('topic_comment' => record)
end

#topic_comment_paramsObject



17
18
19
# File 'lib/zendesk2/create_topic_comment.rb', line 17

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

#topic_idObject



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

def topic_id
  params.fetch('topic_comment').fetch('topic_id').to_i
end