Current section
Files
Jump to
Current section
Files
lib/wallet_passes/schema/google_callback.ex
defmodule WalletPasses.Schema.GoogleCallback do
@moduledoc "Audit log of Google Wallet save/delete callbacks for a pass."
use Ecto.Schema
import Ecto.Changeset
schema "wallet_passes_google_callbacks" do
belongs_to :google_pass, WalletPasses.Schema.GooglePass
field :event_type, :string
field :object_id, :string
field :class_id, :string
field :nonce, :string
field :exp_time_millis, :integer
field :received_at, :utc_datetime_usec
end
@required ~w(event_type object_id class_id nonce received_at)a
@optional ~w(exp_time_millis)a
def changeset(callback, attrs) do
callback
|> cast(attrs, @required ++ @optional)
|> validate_required(@required)
|> validate_inclusion(:event_type, ["save", "del"])
|> unique_constraint([:google_pass_id, :nonce],
name: :wallet_passes_google_callbacks_google_pass_id_nonce_index
)
end
end