From b49eb87e78bad67bbb3ad32cb8080d9ce777bcce Mon Sep 17 00:00:00 2001 From: Rainer Borene Date: Sat, 16 Nov 2024 18:03:57 -0300 Subject: [PATCH] Add route for clearing unsubscribes and complaints --- lib/mailgunner/client/suppressions.rb | 8 ++++++++ spec/mailgunner/client_spec.rb | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/mailgunner/client/suppressions.rb b/lib/mailgunner/client/suppressions.rb index 992ddcf..286cdfa 100644 --- a/lib/mailgunner/client/suppressions.rb +++ b/lib/mailgunner/client/suppressions.rb @@ -34,6 +34,10 @@ def delete_unsubscribe(address_or_id) delete("/v3/#{escape @domain}/unsubscribes/#{escape address_or_id}") end + def delete_unsubscribes + delete("/v3/#{escape @domain}/unsubscribes") + end + def add_unsubscribe(attributes = ATTRIBUTES) post("/v3/#{escape @domain}/unsubscribes", attributes) end @@ -54,6 +58,10 @@ def delete_complaint(address) delete("/v3/#{escape @domain}/complaints/#{escape address}") end + def delete_complaints + delete("/v3/#{escape @domain}/complaints") + end + def get_whitelists(params = PARAMS) get("/v3/#{escape @domain}/whitelists", query: params) end diff --git a/spec/mailgunner/client_spec.rb b/spec/mailgunner/client_spec.rb index a16661f..e2a7cd4 100644 --- a/spec/mailgunner/client_spec.rb +++ b/spec/mailgunner/client_spec.rb @@ -315,6 +315,14 @@ def stub(http_method, url, body: nil, headers: nil) end end + describe '#delete_unsubscribes' do + it 'returns a response struct' do + stub(:delete, "#{base_url}/v3/#{domain}/unsubscribes") + + expect(client.delete_unsubscribes).to eq(response_struct) + end + end + describe '#add_unsubscribe' do it 'returns a response struct' do stub(:post, "#{base_url}/v3/#{domain}/unsubscribes", body: "address=#{encoded_address}") @@ -361,6 +369,14 @@ def stub(http_method, url, body: nil, headers: nil) end end + describe '#delete_complaints' do + it 'returns a response struct' do + stub(:delete, "#{base_url}/v3/#{domain}/complaints") + + expect(client.delete_complaints).to eq(response_struct) + end + end + describe '#get_bounces' do it 'returns a response struct' do stub(:get, "#{base_url}/v3/#{domain}/bounces")