diff --git a/CHANGELOG.md b/CHANGELOG.md index 832f775..f4d5d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ [non-breaking changes] - remove `test.exs` +- update `mapail` dependency to `1.0` - `Mapail` api changed. ## v0.3.1 diff --git a/lib/openstex/keystone/v2/helpers.ex b/lib/openstex/keystone/v2/helpers.ex index 1d3e8a7..c25380f 100644 --- a/lib/openstex/keystone/v2/helpers.ex +++ b/lib/openstex/keystone/v2/helpers.ex @@ -132,48 +132,72 @@ defmodule Openstex.Keystone.V2.Helpers do defmodule Identity.Token.Tenant do @moduledoc :false defstruct [:description, :enabled, :id, :name] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity.Token do @moduledoc :false defstruct [:audit_ids, :issued_at, :expires, :id, tenant: %Identity.Token.Tenant{}] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity.Service do @moduledoc :false defstruct [endpoints: [], endpoints_links: [], type: "", name: ""] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity.Endpoint do @moduledoc :false defstruct [:admin_url, :region, :internal_url, :id, :public_url] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity.User do @moduledoc :false defstruct [:username, :roles_links, :id, :roles, :name] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity.Metadata do @moduledoc :false defstruct [:metadata, :is_admin, :roles] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity.Trust do @moduledoc :false defstruct [:trust, :id, :trustee_user_id, :trustor_user_id, :impersonation] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end defmodule Identity do @moduledoc :false defstruct [ - token: %Identity.Token{}, - service_catalog: [], - user: %Identity.User{}, - metadata: %Identity.Metadata{}, - trust: %Identity.Trust{} - ] - def build(map), do: Mapail.map_to_struct!(map, __MODULE__, [rest: :merge]) + token: %Identity.Token{}, + service_catalog: [], + user: %Identity.User{}, + metadata: %Identity.Metadata{}, + trust: %Identity.Trust{} + ] + def build(map) do + opts = [rest: :merge, transformations: [:snake_case]] + Mapail.map_to_struct!(map, __MODULE__, opts) + end end diff --git a/mix.exs b/mix.exs index 0feedf5..88cf390 100644 --- a/mix.exs +++ b/mix.exs @@ -1,6 +1,6 @@ defmodule Openstex.Mixfile do use Mix.Project - @version "0.3.1" + @version "0.3.2" @elixir "~> 1.4 or ~> 1.5" def project do @@ -31,7 +31,7 @@ defmodule Openstex.Mixfile do [ # deps {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0"}, - {:mapail, "~> 0.2"}, + {:mapail, "~> 1.0"}, {:httpipe, "~> 0.9"}, # dev deps