lib/fanforce/utils.rb in fanforce-0.3.19 vs lib/fanforce/utils.rb in fanforce-0.4.1

- old
+ new

@@ -19,26 +19,26 @@ end def valid_fanforce_request?(params=@params) return false if !params.is_a?(Hash) return false if is_blank?(params[:fanforce_id]) - return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_id]) and is_blank?(params[:module_id]) and is_blank?(params[:widget_id]) + return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_plugin_id]) and is_blank?(params[:plugin_id]) and is_blank?(params[:widget_id]) return true end def valid_install_request?(params=@params) return false if !params.is_a?(Hash) return false if is_blank?(params[:fanforce_id]) - return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_id]) and is_blank?(params[:module_id]) and is_blank?(params[:widget_id]) + return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_plugin_id]) and is_blank?(params[:plugin_id]) and is_blank?(params[:widget_id]) return false if is_blank?(params[:api_key]) return true end def valid_uninstall_request?(params=@params) return false if !params.is_a?(Hash) return false if is_blank?(params[:fanforce_id]) - return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_id]) and is_blank?(params[:module_id]) and is_blank?(params[:widget_id]) + return false if is_blank?(params[:app_id]) and is_blank?(params[:behavior_plugin_id]) and is_blank?(params[:plugin_id]) and is_blank?(params[:widget_id]) return false if is_blank?(params[:api_key]) return true end def remove_nil_values(hash) @@ -46,26 +46,26 @@ end def collect_known_params(params) params = params.symbolize_keys if is_present?(params[:app_id]) - plugin_type = :app - plugin_id = params[:app_id] - elsif is_present?(params[:behavior_id]) - plugin_type = :behavior - plugin_id = params[:behavior_id] - elsif is_present?(params[:module_id]) - plugin_type = :module - plugin_id = params[:module_id] + addon_type = :app + addon_id = params[:app_id] + elsif is_present?(params[:behavior_plugin_id]) + addon_type = :plugin + addon_id = params[:behavior_plugin_id] + elsif is_present?(params[:plugin_id]) + addon_type = :plugin + addon_id = params[:plugin_id] elsif is_present?(params[:widget_id]) - plugin_type = :widget - plugin_id = params[:widget_id] + addon_type = :widget + addon_id = params[:widget_id] end - remove_nil_values(:"#{plugin_type}_id" => params[:"#{plugin_type}_id"], plugin_type: plugin_type, plugin_id: plugin_id, fanforce_id: params[:fanforce_id], fanforce_slug: params[:fanforce_slug], api_key: params[:api_key], session_id: params[:session_id]) + remove_nil_values(:"#{addon_type}_id" => params[:"#{addon_type}_id"], addon_type: addon_type, addon_id: addon_id, fanforce_id: params[:fanforce_id], fanforce_slug: params[:fanforce_slug], api_key: params[:api_key], session_id: params[:session_id]) end def remove_internal_params(params) - params.clone.delete_if { |k,v| [:app_id, :behavior_id, :module_id, :widget_id, :plugin_type, :plugin_id, :fanforce_id, :fanforce_slug, :api_key].include? k } + params.clone.delete_if { |k,v| [:app_id, :behavior_plugin_id, :plugin_id, :widget_id, :addon_type, :addon_id, :fanforce_id, :fanforce_slug, :api_key].include? k } end def remove_sensitive_params(params) params.clone.delete_if { |k,v| [:api_key].include? k } end