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 - integer - User ID.  Provide a value of `0` to operate the current session's user.
file_comment_id (required) - integer - ID of file comment to attach reaction to.
emoji (required) - string - Emoji to react with.


75
76
77
78
79
80
81
82
83
84
# File 'lib/files.com/models/file_comment_reaction.rb', line 75

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

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

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



86
87
88
89
90
91
92
93
94
# File 'lib/files.com/models/file_comment_reaction.rb', line 86

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

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

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



96
97
98
# File 'lib/files.com/models/file_comment_reaction.rb', line 96

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
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.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

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

#destroy(params = {}) ⇒ Object



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

def destroy(params = {})
  delete(params)
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



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

def save
  if @attributes[:id]
    raise NotImplementedError.new("The FileCommentReaction object doesn't support updates.")
  else
    new_obj = FileCommentReaction.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
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