Skip to content

Commit 28179a4

Browse files
kelostradalukaszsamson
authored andcommitted
handle no changes for recipient
1 parent 6511661 commit 28179a4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/sendgrid/marketing_campaigns/contacts/recipients.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ defmodule SendGrid.Contacts.Recipients do
4242

4343
{:error, errors}
4444
end
45-
4645
# Handles the result when it's valid.
4746
defp handle_recipient_result(%{body: %{"persisted_recipients" => [recipient_id]}}) do
4847
{:ok, recipient_id}
4948
end
49+
50+
# Handles the result when there were no returned recipients (for example if it's an update which didn't change anything)
51+
defp handle_recipient_result(%{body: %{"persisted_recipients" => []}}) do
52+
{:error, ["No changes applied for recipient"]}
53+
end
54+
55+
defp handle_recipient_result(_) do
56+
{:error, ["Unexpected error"]}
57+
end
5058
end

0 commit comments

Comments
 (0)