From e0c975936545b5aea2dc82c25464fcbed68be0f1 Mon Sep 17 00:00:00 2001 From: Prasad Anne Date: Fri, 28 Feb 2020 07:19:20 -0500 Subject: [PATCH] Favourite filters for the user Branch: "filters" | Commit Type: "New feature" | Changes tested: "yes" --- lib/jira/base_factory.rb | 2 +- lib/jira/resource/filter.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/jira/base_factory.rb b/lib/jira/base_factory.rb index 230b2d9a..03a4b63b 100644 --- a/lib/jira/base_factory.rb +++ b/lib/jira/base_factory.rb @@ -36,7 +36,7 @@ def self.delegate_to_target_class(*method_names) # The principle purpose of this class is to delegate methods to the corresponding # non-factory class and automatically prepend the client argument to the argument # list. - delegate_to_target_class :all, :find, :collection_path, :singular_path, :jql, :get_backlog_issues, :get_board_issues, :get_sprints, :get_sprint_issues, :get_projects, :get_projects_full + delegate_to_target_class :all, :find, :collection_path, :singular_path, :jql, :get_backlog_issues, :get_board_issues, :get_sprints, :get_sprint_issues, :get_projects, :get_projects_full, :favourites # This method needs special handling as it has a default argument value def build(attrs = {}) diff --git a/lib/jira/resource/filter.rb b/lib/jira/resource/filter.rb index 8a42d319..eac91773 100644 --- a/lib/jira/resource/filter.rb +++ b/lib/jira/resource/filter.rb @@ -10,6 +10,15 @@ class Filter < JIRA::Base def issues Issue.jql(client, jql) end + + # Returns all the favourite filters for the user + def self.favourites(client, options = {}) + search_url = client.options[:rest_base_path] + '/filter/favourite' + response = client.get(url_with_query_params(search_url, options)) + + json = parse_json(response.body) + client.Filter.build(json) + end end end end