Conversation
| end | ||
| end | ||
|
|
||
| @doc """ |
There was a problem hiding this comment.
The docs don't match the functionality here.
| @doc """ | |
| @doc """ | |
| Adds multiple recipients to an email list. | |
| :ok = add_recipienst(123, ["recipient_id_1"]) | |
| """ |
|
|
||
| """ | ||
| @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.
I'd prefer the name to be add_recipients.
| 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.
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.
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.
| } | ||
| ] | ||
| """ | ||
| @spec add_multiple([]) :: { :ok, [String.t] } | { :ok, String.t } | { :error, list(String.t) } |
There was a problem hiding this comment.
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()} |
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