Class: Zensana::Zendesk::Comment

Inherits:
Object
  • Object
show all
Includes:
Validate::Key
Defined in:
lib/zensana/models/zendesk/comment.rb

Constant Summary collapse

REQUIRED_KEYS =
[ :author_id, :value ]
OPTIONAL_KEYS =
[ :created_at, :public, :uploads ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validate::Key

#has_required_keys?, #has_unknown_keys?, #optional_keys, #required_keys, #valid_keys, #validate_keys

Constructor Details

#initialize(attributes) ⇒ Comment

Returns a new instance of Comment.



16
17
18
19
# File 'lib/zensana/models/zendesk/comment.rb', line 16

def initialize(attributes)
  validate_keys attributes
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



27
28
29
# File 'lib/zensana/models/zendesk/comment.rb', line 27

def method_missing(name, *args, &block)
  attributes[name.to_s] || super
end

Instance Attribute Details

#attributesObject (readonly)

Class validates the comment attributes added during the Ticket Import call. Comments cannot be created this way for existing tickets.



14
15
16
# File 'lib/zensana/models/zendesk/comment.rb', line 14

def attributes
  @attributes
end

Instance Method Details

#author_exists?(id) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/zensana/models/zendesk/comment.rb', line 21

def author_exists?(id)
  !! Zendesk::User.new.find(id)
rescue NotFound
  false
end