# frozen_string_literal: true module Files class Style attr_reader :options, :attributes def initialize(attributes = {}, options = {}) @attributes = attributes || {} @options = options || {} end # int64 - Style ID def id @attributes[:id] end def id=(value) @attributes[:id] = value end # string - Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters. def path @attributes[:path] end def path=(value) @attributes[:path] = value end # Image - Logo def logo @attributes[:logo] end def logo=(value) @attributes[:logo] = value end # Image - Logo thumbnail def thumbnail @attributes[:thumbnail] end def thumbnail=(value) @attributes[:thumbnail] = value end # file - Logo for custom branding. def file @attributes[:file] end def file=(value) @attributes[:file] = value end # Parameters: # file (required) - file - Logo for custom branding. def update(params = {}) params ||= {} params[:path] = @attributes[:path] raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path] raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] raise MissingParameterError.new("Parameter missing: file") unless params[:file] Api.send_request("/styles/#{@attributes[:path]}", :patch, params, @options) end def delete(params = {}) params ||= {} params[:path] = @attributes[:path] raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path] raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] Api.send_request("/styles/#{@attributes[:path]}", :delete, params, @options) end def destroy(params = {}) delete(params) nil end def save new_obj = update(@attributes) @attributes = new_obj.attributes true end # Parameters: # path (required) - string - Style path. def self.find(path, params = {}, options = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] response, options = Api.send_request("/styles/#{params[:path]}", :get, params, options) Style.new(response.data, options) end def self.get(path, params = {}, options = {}) find(path, params, options) end # Parameters: # file (required) - file - Logo for custom branding. def self.update(path, params = {}, options = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] raise MissingParameterError.new("Parameter missing: file") unless params[:file] response, options = Api.send_request("/styles/#{params[:path]}", :patch, params, options) Style.new(response.data, options) end def self.delete(path, params = {}, options = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] Api.send_request("/styles/#{params[:path]}", :delete, params, options) nil end def self.destroy(path, params = {}, options = {}) delete(path, params, options) nil end end end