# frozen_string_literal: true module Files class MessageCommentReaction attr_reader :options, :attributes def initialize(attributes = {}, options = {}) @attributes = attributes || {} @options = options || {} end # int64 - Reaction ID def id @attributes[:id] end def id=(value) @attributes[:id] = value end # string - Emoji used in the reaction. def emoji @attributes[:emoji] end def emoji=(value) @attributes[:emoji] = value end # int64 - User ID. Provide a value of `0` to operate the current session's user. def user_id @attributes[:user_id] end def user_id=(value) @attributes[:user_id] = value end 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("/message_comment_reactions/#{@attributes[:id]}", :delete, params, @options) end def destroy(params = {}) delete(params) end def save if @attributes[:id] raise NotImplementedError.new("The MessageCommentReaction object doesn't support updates.") else new_obj = MessageCommentReaction.create(@attributes, @options) @attributes = new_obj.attributes end end # Parameters: # user_id - integer - User ID. Provide a value of `0` to operate the current session's user. # page - integer - Current page number. # per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended). # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves. # message_comment_id (required) - integer - Message comment to return reactions for. def self.list(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: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: message_comment_id must be an Integer") if params.dig(:message_comment_id) and !params.dig(:message_comment_id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: message_comment_id") unless params.dig(:message_comment_id) response, options = Api.send_request("/message_comment_reactions", :get, params, options) response.data.map { |object| MessageCommentReaction.new(object, options) } end def self.all(params = {}, options = {}) list(params, options) end # Parameters: # id (required) - integer - Message Comment Reaction ID. def self.find(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("/message_comment_reactions/#{params[:id]}", :get, params, options) MessageCommentReaction.new(response.data, options) end def self.get(id, params = {}, options = {}) find(id, params, options) end # Parameters: # user_id - integer - User ID. Provide a value of `0` to operate the current session's user. # emoji (required) - string - Emoji to react with. 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: emoji must be an String") if params.dig(:emoji) and !params.dig(:emoji).is_a?(String) raise MissingParameterError.new("Parameter missing: emoji") unless params.dig(:emoji) response, options = Api.send_request("/message_comment_reactions", :post, params, options) MessageCommentReaction.new(response.data, options) end 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("/message_comment_reactions/#{params[:id]}", :delete, params, options) response.data end def self.destroy(id, params = {}, options = {}) delete(id, params, options) end end end