-
Notifications
You must be signed in to change notification settings - Fork 46
Feature/multiple recipients #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature/multiple recipients #25
Conversation
| end | ||
| end | ||
|
|
||
| @doc """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs don't match the functionality here.
| @doc """ | |
| @doc """ | |
| Adds multiple recipients to an email list. | |
| :ok = add_recipienst(123, ["recipient_id_1"]) | |
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| """ | ||
| @spec add_multiple_recipients(integer, [String.t()]) :: :ok | :error | ||
| def add_multiple_recipients(list_id, recipient_ids) when is_list(recipient_ids) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the name to be add_recipients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| def search(opts) do | ||
| query = URI.encode_query(opts) | ||
| SendGrid.get("#{@base_api_url}/search?#{query}") | ||
| |> handle_search_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function may have been missed during the commit. I'm not seeing it in the changes.
| end | ||
|
|
||
| # Handles the result when there are multiple persisted recipients. | ||
| defp handle_recipient_result({:ok, %{body: %{"persisted_recipients" => recipients}}}) when is_list(recipients) and length(recipients) > 1 do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the list of persisted recipients may not be the length of the list passed to the request, I think that adding multiple recipients should just return the the body of the response instead. It's straightforward when just adding a single recipient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
| ] | ||
| """ | ||
| @spec add_multiple([]) :: { :ok, [String.t] } | { :ok, String.t } | { :error, list(String.t) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to the comment about the return for this function.
| @spec add_multiple([]) :: { :ok, [String.t] } | { :ok, String.t } | { :error, list(String.t) } | |
| @spec add_multiple([String.t()]) :: {:ok, map()} | {:error, any()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
82e5c67 to
76d7cac
Compare
|
@alexgaribay I rebased this PR and applied your suggestions. Can you merge it now? |
added functions to handle adding multiple recipients