# frozen_string_literal: true module Files class BundleNotification attr_reader :options, :attributes def initialize(attributes = {}, options = {}) @attributes = attributes || {} @options = options || {} end # int64 - Bundle ID to notify on def bundle_id @attributes[:bundle_id] end def bundle_id=(value) @attributes[:bundle_id] = value end # int64 - Bundle Notification ID def id @attributes[:id] end def id=(value) @attributes[:id] = value end # boolean - Triggers bundle notification when a registration action occurs for it. def notify_on_registration @attributes[:notify_on_registration] end def notify_on_registration=(value) @attributes[:notify_on_registration] = value end # boolean - Triggers bundle notification when a upload action occurs for it. def notify_on_upload @attributes[:notify_on_upload] end def notify_on_upload=(value) @attributes[:notify_on_upload] = value end # int64 - The id of the user to notify. def user_id @attributes[:user_id] end def user_id=(value) @attributes[:user_id] = value end # Parameters: # notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it. # notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it. def update(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("/bundle_notifications/#{@attributes[:id]}", :patch, params, @options) 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("/bundle_notifications/#{@attributes[:id]}", :delete, params, @options) end def destroy(params = {}) delete(params) end def save if @attributes[:id] update(@attributes) else new_obj = BundleNotification.create(@attributes, @options) @attributes = new_obj.attributes end end # Parameters: # user_id - int64 - User ID. Provide a value of `0` to operate the current session's user. # cursor - string - Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header. # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended). # bundle_id - int64 - Bundle ID to notify on 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: bundle_id must be an Integer") if params[:bundle_id] and !params[:bundle_id].is_a?(Integer) List.new(BundleNotification, params) do Api.send_request("/bundle_notifications", :get, params, options) end end def self.all(params = {}, options = {}) list(params, options) end # Parameters: # id (required) - int64 - Bundle Notification 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("/bundle_notifications/#{params[:id]}", :get, params, options) BundleNotification.new(response.data, options) end def self.get(id, params = {}, options = {}) find(id, params, options) end # Parameters: # user_id (required) - int64 - The id of the user to notify. # notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it. # notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it. # bundle_id (required) - int64 - Bundle ID to notify on 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: bundle_id must be an Integer") if params[:bundle_id] and !params[:bundle_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: user_id") unless params[:user_id] raise MissingParameterError.new("Parameter missing: bundle_id") unless params[:bundle_id] response, options = Api.send_request("/bundle_notifications", :post, params, options) BundleNotification.new(response.data, options) end # Parameters: # notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it. # notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it. def self.update(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("/bundle_notifications/#{params[:id]}", :patch, params, options) BundleNotification.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[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, _options = Api.send_request("/bundle_notifications/#{params[:id]}", :delete, params, options) response.data end def self.destroy(id, params = {}, options = {}) delete(id, params, options) end end end