Add group owner add and remove methods (#239)

Add group owner add and remove methods (#239)

Added two new methods for adding or removing group owners and update some outdated params for the update user method.

diff --git a/lib/discourse_api/api/groups.rb b/lib/discourse_api/api/groups.rb
index 72bfdf0..be254d0 100644
--- a/lib/discourse_api/api/groups.rb
+++ b/lib/discourse_api/api/groups.rb
@@ -38,7 +38,6 @@ module DiscourseApi
                             :messageable_level,
                             :name,
                             :automatic_membership_email_domains,
-                            :automatic_membership_retroactive,
                             :title,
                             :primary_group,
                             :grant_trust_level,
@@ -47,19 +46,31 @@ module DiscourseApi
                             :flair_bg_color,
                             :flair_color,
                             :bio_raw,
-                            :members_visibility_level,
+                            :visibility_level,
                             :public_admission,
                             :public_exit,
                             :allow_membership_requests,
                             :full_name,
                             :default_notification_level,
-                            :usernames,
-                            :owner_usernames,
                             :membership_request_template)
           .to_h
         put("/groups/#{group_id}", group: args)
       end
 
+      def group_add_owners(group_id, args)
+        args = API.params(args)
+          .required(:usernames)
+          .to_h
+        put("/admin/groups/#{group_id}/owners.json", group: args)
+      end
+
+      def group_remove_owners(group_id, args)
+        args = API.params(args)
+          .required(:usernames)
+          .to_h
+        delete("/admin/groups/#{group_id}/owners.json", group: args)
+      end
+
       def groups(args = {})
         params = API.params(args)
           .optional(:page)
diff --git a/spec/discourse_api/api/groups_spec.rb b/spec/discourse_api/api/groups_spec.rb
index 2468220..d9ee6d7 100644
--- a/spec/discourse_api/api/groups_spec.rb
+++ b/spec/discourse_api/api/groups_spec.rb
@@ -91,6 +91,35 @@ describe DiscourseApi::API::Groups do
       end
     end
 
+    describe "add owners" do
+      let(:url) { "#{host}/admin/groups/123/owners.json" }
+
+      before do
+        stub_put(url)
+      end
+
+      it "makes the member an owner" do
+        subject.group_add_owners(123, usernames: "sam")
+        params = escape_params("group[usernames]" => "sam")
+        expect(a_request(:put, "#{host}/admin/groups/123/owners.json").
+                with(body: params)
+              ).to have_been_made
+      end
+    end
+
+    describe "remove owners" do
+      let(:url) { "#{host}/admin/groups/123/owners.json?group%5Busernames%5D=sam" }
+
+      before do
+        stub_delete(url)
+      end
+
+      it "removes the owner role from the group member" do
+        subject.group_remove_owners(123, usernames: "sam")
+        expect(a_delete(url)).to have_been_made
+      end
+    end
+
     describe "group members" do
       it "list members" do
         stub_get("#{host}/groups/mygroup/members.json?limit=100&offset=0").to_return(body: fixture("members_0.json"), headers: { content_type: "application/json" })

GitHub sha: e3fd241c5b5b35264a938ed525f731cffcee30e1

This commit appears in #239 which was approved by eviltrout. It was merged by blake.