Class: Files::FileCommentReaction

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/file_comment_reaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ FileCommentReaction

Returns a new instance of FileCommentReaction.



7
8
9
10
# File 'lib/files.com/models/file_comment_reaction.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/file_comment_reaction.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/file_comment_reaction.rb', line 5

def options
  @options
end

Class Method Details

.create(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
file_comment_id (required) - int64 - ID of file comment to attach reaction to.
emoji (required) - string - Emoji to react with.


78
79
80
81
82
83
84
85
86
87
# File 'lib/files.com/models/file_comment_reaction.rb', line 78

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: file_comment_id must be an Integer") if params[:file_comment_id] and !params[:file_comment_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: emoji must be an String") if params[:emoji] and !params[:emoji].is_a?(String)
  raise MissingParameterError.new("Parameter missing: file_comment_id") unless params[:file_comment_id]
  raise MissingParameterError.new("Parameter missing: emoji") unless params[:emoji]

  response, options = Api.send_request("/file_comment_reactions", :post, params, options)
  FileCommentReaction.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/files.com/models/file_comment_reaction.rb', line 89

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/file_comment_reactions/#{params[:id]}", :delete, params, options)
  nil
end

.destroy(id, params = {}, options = {}) ⇒ Object



99
100
101
102
# File 'lib/files.com/models/file_comment_reaction.rb', line 99

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
  nil
end

Instance Method Details

#delete(params = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/files.com/models/file_comment_reaction.rb', line 48

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/file_comment_reactions/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



58
59
60
61
# File 'lib/files.com/models/file_comment_reaction.rb', line 58

def destroy(params = {})
  delete(params)
  nil
end

#emojiObject

string - Emoji used in the reaction.



22
23
24
# File 'lib/files.com/models/file_comment_reaction.rb', line 22

def emoji
  @attributes[:emoji]
end

#emoji=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/file_comment_reaction.rb', line 26

def emoji=(value)
  @attributes[:emoji] = value
end

#file_comment_idObject

int64 - ID of file comment to attach reaction to.



40
41
42
# File 'lib/files.com/models/file_comment_reaction.rb', line 40

def file_comment_id
  @attributes[:file_comment_id]
end

#file_comment_id=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/file_comment_reaction.rb', line 44

def file_comment_id=(value)
  @attributes[:file_comment_id] = value
end

#idObject

int64 - Reaction ID



13
14
15
# File 'lib/files.com/models/file_comment_reaction.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/file_comment_reaction.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#saveObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/files.com/models/file_comment_reaction.rb', line 63

def save
  if @attributes[:id]
    raise NotImplementedError.new("The FileCommentReaction object doesn't support updates.")
  else
    new_obj = FileCommentReaction.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#user_idObject

int64 - User ID. Provide a value of ‘0` to operate the current session’s user.



31
32
33
# File 'lib/files.com/models/file_comment_reaction.rb', line 31

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/file_comment_reaction.rb', line 35

def user_id=(value)
  @attributes[:user_id] = value
end