aboutsummaryrefslogtreecommitdiff
path: root/lib/link.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/link.ex')
-rw-r--r--lib/link.ex20
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