Skip to content

Commit

Permalink
Add route for clearing unsubscribes and complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerborene committed Nov 16, 2024
1 parent fb626f5 commit b49eb87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/mailgunner/client/suppressions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/mailgunner/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b49eb87

Please sign in to comment.