From b583e8e1f1fb53694db6353ce3715d2352b75dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Fern=C3=A1ndez?= Date: Sun, 12 May 2024 16:06:14 +0000 Subject: [PATCH] user --- lib/uof/api/mappings/bookmaker_details.ex | 15 ---------- lib/uof/api/users.ex | 34 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 17 deletions(-) delete mode 100644 lib/uof/api/mappings/bookmaker_details.ex diff --git a/lib/uof/api/mappings/bookmaker_details.ex b/lib/uof/api/mappings/bookmaker_details.ex deleted file mode 100644 index 25e4913..0000000 --- a/lib/uof/api/mappings/bookmaker_details.ex +++ /dev/null @@ -1,15 +0,0 @@ -defmodule UOF.API.Mappings.BookmakerDetails do - @moduledoc false - use Saxaboom.Mapper - - @type t :: %__MODULE__{ - expire_at: String.t(), - bookmaker_id: String.t(), - virtual_host: String.t() - } - document do - attribute(:expire_at) - attribute(:bookmaker_id) - attribute(:virtual_host) - end -end diff --git a/lib/uof/api/users.ex b/lib/uof/api/users.ex index 868cbdb..c856269 100644 --- a/lib/uof/api/users.ex +++ b/lib/uof/api/users.ex @@ -2,7 +2,9 @@ defmodule UOF.API.Users do @moduledoc """ API used for administrative purposes. """ - alias UOF.API.Utils.HTTP + use Ecto.Schema + import Ecto.Changeset + import UOF.API.EctoHelpers @doc """ Get information about the token being used, including information such as @@ -11,6 +13,34 @@ defmodule UOF.API.Users do def whoami do endpoint = ["users", "whoami.xml"] - HTTP.get(%UOF.API.Mappings.BookmakerDetails{}, endpoint) + case UOF.API.get("/users/whoami.xml") do + {:ok, %_{status: 200, body: resp}} -> + resp + + # |> Map.get("betstop_reasons_descriptions") + # |> Map.get("betstop_reason") + # |> Enum.map(fn x -> + # {:ok, x} = changeset(x) + # x + # end) + + {:error, _} = error -> + error + end + end + + @primary_key false + + embedded_schema do + field :expire_at, :string + field :bookmaker_id, :string + field :virtual_host, :string + end + + def changeset(model, params) do + params = sanitize(params) + + model + |> cast(params, [:expire_at, :bookmaker_id, :virtual_host]) end end