frenzy/lib/frenzy/approved_client.ex

33 lines
813 B
Elixir

defmodule Frenzy.ApprovedClient do
use Ecto.Schema
import Ecto.Changeset
schema "approved_clients" do
field :client_id, :string
field :auth_code, :string
field :access_token, :string
belongs_to :user, Frenzy.User
timestamps()
end
@type t() :: %__MODULE__{
__meta__: Ecto.Schema.Metadata.t(),
id: integer() | nil,
client_id: String.t(),
auth_code: String.t(),
access_token: String.t(),
user: Frenzy.User.t() | Ecto.Association.NotLoaded.t(),
inserted_at: NaiveDateTime.t(),
updated_at: NaiveDateTime.t()
}
@doc false
def changeset(approved_client, attrs) do
approved_client
|> cast(attrs, [:client_id, :auth_code, :access_token])
|> validate_required([:client_id])
end
end