Skip to content

Commit

Permalink
Merge pull request #18 from libmartinito/add-forget-subscriber-method
Browse files Browse the repository at this point in the history
Add forget subscriber method
  • Loading branch information
dinomh authored Nov 20, 2023
2 parents 4c0b15a + b682963 commit 80f17a6
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
62 changes: 62 additions & 0 deletions fixtures/subscribers/forget.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/mailerlite/subscribers/subscribers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,13 @@ def fetch_count
def delete(subscriber_id)
client.http.delete("#{API_URL}/subscribers/#{subscriber_id}")
end

# Forgets the specified subscriber.
#
# @param subscriber_id [String] the ID of the subscriber to forget
# @return [HTTP::Response] the response from the API
def forget(subscriber_id)
client.http.post("#{API_URL}/subscribers/#{subscriber_id}/forget")
end
end
end
12 changes: 12 additions & 0 deletions spec/subscribers_rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,16 @@
end
end
end

describe '#forget' do
# Use VCR to record and replay the HTTP request
it 'forgets a subscriber' do
VCR.use_cassette('subscribers/forget') do
response = subscribers.forget(98_121_614_828_242_796)
body = JSON.parse(response.body)
expect(response.status).to eq 200
expect(body['message']).to eq 'Subscriber data will be completely deleted and forgotten within 30 days.'
end
end
end
end

0 comments on commit 80f17a6

Please sign in to comment.