diff options
author | Rawane Zossou <dev@raw1z.fr> | 2015-09-19 02:49:52 +0200 |
---|---|---|
committer | Rawane Zossou <dev@raw1z.fr> | 2015-09-19 02:50:44 +0200 |
commit | cedebfbae736e26d5d96129bb46dd868de8e1224 (patch) | |
tree | 72e7a660b6476ea3402ca45f53746d4abf96697c /lib/link.ex | |
parent | 818c1bb791a30a88df54c286a3cb1571845a3d27 (diff) | |
download | mailchimp-cedebfbae736e26d5d96129bb46dd868de8e1224.tar.gz mailchimp-cedebfbae736e26d5d96129bb46dd868de8e1224.tar.xz |
refactor the account and list modules
Diffstat (limited to 'lib/link.ex')
-rw-r--r-- | lib/link.ex | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/link.ex b/lib/link.ex new file mode 100644 index 0000000..fc355b9 --- /dev/null +++ b/lib/link.ex @@ -0,0 +1,20 @@ +defmodule Mailchimp.Link do + defstruct rel: nil, href: nil, method: nil, schema: nil, target_schema: nil + + def new(attributes) do + %__MODULE__{ + rel: attributes[:rel], + href: attributes[:href], + method: attributes[:method], + schema: attributes[:schema], + target_schema: attributes[:targetSchema] + } + end + + def get_links_from_attributes(attributes) do + (attributes._links || []) + |> Enum.map(&__MODULE__.new(&1)) + |> Enum.map(&({&1.rel, &1})) + |> Enum.into(%{}) + end +end |