Skip to content
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

Adding an endpoint /contact/{contact_ID}/getcontactslists #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/mailjex/api/contact.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions lib/mailjex/behaviours/contact.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions lib/mailjex/contact.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
##########################
Expand All @@ -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