Class: Zendesk2::TopicComment

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Includes:
Model
Defined in:
lib/zendesk2/topic_comment.rb

Instance Attribute Summary

Attributes included from Model

#errors

Instance Method Summary collapse

Methods included from Attributes

assoc_accessor, assoc_reader, assoc_writer

Methods included from Model

#destroy, #destroyed?, #missing_attributes, #save, #update!

Instance Method Details

#attachmentsArray

Returns Attachments to this comment as Attachment objects.

Returns:

  • (Array)

    Attachments to this comment as Attachment objects



11
# File 'lib/zendesk2/topic_comment.rb', line 11

attribute :attachments, type: :array

#bodyString

Returns The comment body.

Returns:

  • (String)

    The comment body



13
# File 'lib/zendesk2/topic_comment.rb', line 13

attribute :body, type: :string

#created_atTime

Returns The time the topic_comment was created.

Returns:

  • (Time)

    The time the topic_comment was created



15
# File 'lib/zendesk2/topic_comment.rb', line 15

attribute :created_at, type: :time

#destroy!Object



30
31
32
33
34
# File 'lib/zendesk2/topic_comment.rb', line 30

def destroy!
  requires :identity

  cistern.destroy_topic_comment('topic_comment' => { 'id' => identity, 'topic_id' => topic_id })
end

#idInteger

Returns Automatically assigned upon creation.

Returns:

  • (Integer)

    Automatically assigned upon creation



8
# File 'lib/zendesk2/topic_comment.rb', line 8

identity :id, type: :integer

#informativeBoolean

Returns If the comment has been flagged as informative.

Returns:

  • (Boolean)

    If the comment has been flagged as informative



17
# File 'lib/zendesk2/topic_comment.rb', line 17

attribute :informative, type: :boolean

#reloadObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/zendesk2/topic_comment.rb', line 50

def reload
  requires :identity

  data = cistern.topic_comments('topic_id' => topic_id).get(identity)

  return unless data

  new_attributes = data.attributes
  merge_attributes(new_attributes)
  self
end

#save!Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/zendesk2/topic_comment.rb', line 36

def save!
  response = if new_record?
               requires :topic_id, :user_id, :body

               cistern.create_topic_comment('topic_comment' => attributes)
             else
               requires :identity

               cistern.update_topic_comment('topic_comment' => attributes)
             end

  merge_attributes(response.body['topic_comment'])
end

#topic_idInteger

Returns The id of the topic this comment was made on.

Returns:

  • (Integer)

    The id of the topic this comment was made on



19
# File 'lib/zendesk2/topic_comment.rb', line 19

attribute :topic_id, type: :integer

#updated_atTime

Returns The time of the last update of the topic_comment.

Returns:

  • (Time)

    The time of the last update of the topic_comment



21
# File 'lib/zendesk2/topic_comment.rb', line 21

attribute :updated_at, type: :time

#urlString

Returns The API url of this topic comment.

Returns:

  • (String)

    The API url of this topic comment



23
# File 'lib/zendesk2/topic_comment.rb', line 23

attribute :url, type: :string

#user_idInteger

Returns The id of the user making the topic comment.

Returns:

  • (Integer)

    The id of the user making the topic comment



25
# File 'lib/zendesk2/topic_comment.rb', line 25

attribute :user_id, type: :integer