diff options
author | Joshua Rieken <joshua@joshuarieken.com> | 2015-09-29 16:36:27 -0700 |
---|---|---|
committer | Joshua Rieken <joshua@joshuarieken.com> | 2015-09-29 16:36:27 -0700 |
commit | 052211e0af39f4144c78d8efadc8987be2976d92 (patch) | |
tree | 26146f9d18ae0e2a3b40db4ffb579c9ad4573d0d | |
parent | fec7b046083d6fdad576c5dff3bf4b70a5eb7628 (diff) | |
download | mailchimp-052211e0af39f4144c78d8efadc8987be2976d92.tar.gz mailchimp-052211e0af39f4144c78d8efadc8987be2976d92.tar.xz |
Add add_pending_member function
-rw-r--r-- | lib/list.ex | 7 | ||||
-rw-r--r-- | lib/mailchimp.ex | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/list.ex b/lib/list.ex index 43ec63a..8589eb2 100644 --- a/lib/list.ex +++ b/lib/list.ex @@ -21,6 +21,13 @@ defmodule Mailchimp.List do |> post(body, map_header) end + def add_pending_member(config, %{"list_id" => list_id, "email" => email}) do + map_header = %{"Authorization" => "apikey #{config.apikey}"} + {:ok, body} = Poison.encode(%{email_address: email, status: "pending"}) + config.apiroot <> "lists/" <> list_id <> "/members" + |> post(body, map_header) + end + def build_url(root) do params = [ {:fields, ["lists.id", "lists.name", "lists.stats.member_count"]}, diff --git a/lib/mailchimp.ex b/lib/mailchimp.ex index 144168d..15f5323 100644 --- a/lib/mailchimp.ex +++ b/lib/mailchimp.ex @@ -29,6 +29,10 @@ defmodule Mailchimp do GenServer.call(:mailchimp, {:add_member, list_id, email}) end + def add_pending_member(list_id, email) do + GenServer.call(:mailchimp, {:add_pending_member, list_id, email}) + end + ### Server API def handle_call(:account_details, _from, config) do details = Mailchimp.Account.get_details(config) |