From 76c4cebded319861e4e8b2237e50eb83316c7c65 Mon Sep 17 00:00:00 2001 From: Bartosz Kalinowski Date: Wed, 13 Sep 2017 14:46:23 +0200 Subject: [PATCH] handle no changes for recipient --- lib/sendgrid/marketing_campaigns/contacts/recipients.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/sendgrid/marketing_campaigns/contacts/recipients.ex b/lib/sendgrid/marketing_campaigns/contacts/recipients.ex index 0f3e1b1..c452b88 100644 --- a/lib/sendgrid/marketing_campaigns/contacts/recipients.ex +++ b/lib/sendgrid/marketing_campaigns/contacts/recipients.ex @@ -47,4 +47,13 @@ defmodule SendGrid.Contacts.Recipients do defp handle_recipient_result(%{body: %{"persisted_recipients" => [recipient_id]}}) do {:ok, recipient_id} end + + # Handles the result when there were no returned recipients (for example if it's an update which didn't change anything) + defp handle_recipient_result(%{body: %{"persisted_recipients" => []}}) do + {:error, ["No changes applied for recipient"]} + end + + defp handle_recipient_result(_) do + {:error, ["Unexpected error"]} + end end