From 8e186bbba89f8c0def54d6ae3775cab2fc3c47e5 Mon Sep 17 00:00:00 2001 From: dwarner <175417+dwarner@users.noreply.github.com> Date: Sun, 17 Nov 2019 12:21:48 -0500 Subject: [PATCH] Adding an endpoint /contact/{contact_ID}/getcontactslists Retrieve all contact lists for a specific contact. https://dev.mailjet.com/email/reference/contacts/subscriptions/#v3_get_contact_contact_ID_getcontactslists --- lib/mailjex/api/contact.ex | 5 +++++ lib/mailjex/behaviours/contact.ex | 1 + lib/mailjex/contact.ex | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/mailjex/api/contact.ex b/lib/mailjex/api/contact.ex index 6167db6..42cd447 100644 --- a/lib/mailjex/api/contact.ex +++ b/lib/mailjex/api/contact.ex @@ -26,4 +26,9 @@ defmodule Mailjex.Api.Contact do request(:post, "/REST/contact/#{id}/managecontactslists", body) |> decode_json end + + def get_contacts_lists(id) do + request(:get, "/REST/contact/#{id}/getcontactslists") + |> decode_json + end end diff --git a/lib/mailjex/behaviours/contact.ex b/lib/mailjex/behaviours/contact.ex index 719e6bb..b245f7f 100644 --- a/lib/mailjex/behaviours/contact.ex +++ b/lib/mailjex/behaviours/contact.ex @@ -6,4 +6,5 @@ defmodule Mailjex.Behaviour.Contact do @callback list() :: tuple() @callback update(integer(), map()) :: tuple() @callback manage_contacts_lists(integer(), map()) :: tuple() + @callback get_contacts_lists(integer()) :: tuple() end diff --git a/lib/mailjex/contact.ex b/lib/mailjex/contact.ex index 1c5ddbe..f58f431 100644 --- a/lib/mailjex/contact.ex +++ b/lib/mailjex/contact.ex @@ -81,6 +81,19 @@ defmodule Mailjex.Contact do GenServer.call(__MODULE__, {:manage_contacts_lists, id, body}) end + @doc """ + + Allows you to retrieve all contact lists + for a specific contact + + ## Examples + + iex> Mailjex.Contact.get_contacts_lists("1234ID") + """ + def get_contacts_lists(id) do + GenServer.call(__MODULE__, {:get_contacts_lists, id}) + end + ########################## # GenServer Callbacks ########################## @@ -104,4 +117,8 @@ defmodule Mailjex.Contact do def handle_call({:manage_contacts_lists, id, body}, _from, state) do {:reply, Contact.manage_contacts_lists(id, body), state} end + + def handle_call({:get_contacts_lists, id}, _from, state) do + {:reply, Contact.get_contacts_lists(id), state} + end end