Current section
Files
Jump to
Current section
Files
lib/resources/endpoint.ex
defmodule Pollin.Resource.Endpoint do
@moduledoc """
Endpoint Resource
"""
@derive [Poison.Encoder]
defstruct [:id, :secret, :phases, :ttl, :created_at]
@type t :: %__MODULE__{
id: charlist,
secret: charlist,
ttl: integer,
phases: list(charlist),
created_at: integer
}
@doc """
Generates new endpoint
"""
def new(phases, ttl \\ 900_000) when is_list(phases) and is_integer(ttl) do
%__MODULE__{
id: SecureRandom.uuid,
secret: SecureRandom.urlsafe_base64(8),
phases: phases,
ttl: ttl,
created_at: :os.system_time
}
end
end