# frozen_string_literal: true module Files class MessageReaction 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[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/message_reactions/#{@attributes[:id]}", :delete, params, @options) end def destroy(params = {}) delete(params) nil end def save if @attributes[:id] raise NotImplementedError.new("The MessageReaction object doesn't support updates.") else new_obj = MessageReaction.create(@attributes, @options) end @attributes = new_obj.attributes true end # Parameters: # user_id - int64 - User ID. Provide a value of `0` to operate the current session's user. # cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination. # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended). # message_id (required) - int64 - Message to return reactions for. def self.list(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: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: message_id must be an Integer") if params[:message_id] and !params[:message_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: message_id") unless params[:message_id] List.new(MessageReaction, params) do Api.send_request("/message_reactions", :get, params, options) end end def self.all(params = {}, options = {}) list(params, options) end # Parameters: # id (required) - int64 - Message Reaction ID. def self.find(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] response, options = Api.send_request("/message_reactions/#{params[:id]}", :get, params, options) MessageReaction.new(response.data, options) end def self.get(id, params = {}, options = {}) find(id, params, options) end # Parameters: # user_id - int64 - 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[:user_id] and !params[:user_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: emoji") unless params[:emoji] response, options = Api.send_request("/message_reactions", :post, params, options) MessageReaction.new(response.data, options) end # Parameters: # user_id - int64 - User ID. Provide a value of `0` to operate the current session's user. # message_id (required) - int64 - Message to return reactions for. def self.create_export(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: message_id must be an Integer") if params[:message_id] and !params[:message_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: message_id") unless params[:message_id] response, options = Api.send_request("/message_reactions/create_export", :post, params, options) response.data.map do |entity_data| Export.new(entity_data, options) end end 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("/message_reactions/#{params[:id]}", :delete, params, options) nil end def self.destroy(id, params = {}, options = {}) delete(id, params, options) nil end end end