Current section

Files

Jump to
bingex lib bingex user data get_uid.ex
Raw

lib/bingex/user/data/get_uid.ex

defmodule Bingex.User.Data.GetUID do
@moduledoc """
Represents response content on `Bingex.User.get_uid` request.
"""
import Bingex.{Helpers, Convertors}
alias Bingex.API.Reply
defstruct [:uid]
@type t() :: %__MODULE__{
uid: nil | binary()
}
@spec embed_in_reply(Reply.t()) :: Reply.t(t())
def embed_in_reply(%Reply{payload: payload} = reply) do
Reply.put_data(reply, decode(payload))
end
@spec decode(any()) :: t()
def decode(%{"data" => data}) when is_map(data) do
%__MODULE__{uid: get_and_transform(data, "uid", &to_binary/1)}
end
def decode(_data), do: %__MODULE__{}
end