Current section

Files

Jump to
merchant lib helpers.ex
Raw

lib/helpers.ex

defmodule Merchant.Helpers do
@moduledoc """
Helper functions for the Merchant API
"""
@spec to_struct(any(), module()) :: list(struct()) | struct() | nil
def to_struct(data, struct) when is_list(data),
do: Enum.map(data, &Mappable.to_struct(&1, struct))
def to_struct(data, struct) when is_map(data), do: Mappable.to_struct(data, struct)
def to_struct(_, _), do: nil
end