DEV: adds method to destroy all expired invites (#232)

DEV: adds method to destroy all expired invites (#232)

diff --git a/examples/invite_users.rb b/examples/invite_users.rb
index 8d8ba7a..cb70af1 100644
--- a/examples/invite_users.rb
+++ b/examples/invite_users.rb
@@ -22,3 +22,6 @@ client.invite_user_to_topic(email: "foo@bar.com", group_ids: "1,2,3", topic_id: 
 
 # retrieve invite
 puts client.retrieve_invite(email: "foo@bar.com")
+
+# destroy all expired invites
+client.destroy_all_expired_invites
diff --git a/lib/discourse_api/api/invite.rb b/lib/discourse_api/api/invite.rb
index 20fd83e..9145b42 100644
--- a/lib/discourse_api/api/invite.rb
+++ b/lib/discourse_api/api/invite.rb
@@ -63,6 +63,10 @@ module DiscourseApi
 
         put("invites/#{invite_id}", args)
       end
+
+      def destroy_all_expired_invites
+        post("invites/destroy-all-expired")
+      end
     end
   end
 end
diff --git a/spec/discourse_api/api/invite_spec.rb b/spec/discourse_api/api/invite_spec.rb
index 314c1a9..1247d32 100644
--- a/spec/discourse_api/api/invite_spec.rb
+++ b/spec/discourse_api/api/invite_spec.rb
@@ -53,4 +53,21 @@ describe DiscourseApi::API::Invite do
       expect(invites).to have_key("invite_key")
     end
   end
+
+  describe "#destroy_all_expired_invites" do
+    let(:url) { "#{host}/invites/destroy-all-expired" }
+
+    before do
+      stub_post(url)
+        .to_return(
+          body: '{"success": "OK"}',
+          headers: { content_type: "application/json" }
+        )
+    end
+
+    it "destroys all expired invites" do
+      subject.destroy_all_expired_invites
+      expect(a_post(url)).to have_been_made
+    end
+  end
 end

GitHub sha: ca5a29da

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