Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule CodeCorps.Repo.Migrations.CreateStripeExternalAccount do
use Ecto.Migration

def change do
create table(:stripe_external_accounts) do
add :id_from_stripe, :string, null: false
add :account_id_from_stripe, :string, null: false
add :account_holder_name, :string
add :account_holder_type, :string
add :bank_name, :string
add :country, :string
add :currency, :string
add :default_for_currency, :string
add :fingerprint, :string
add :last4, :string
add :routing_number, :string
add :status, :string

timestamps()
end

end
end
18 changes: 18 additions & 0 deletions test/models/stripe_external_account_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule CodeCorps.StripeExternalAccountTest do
use CodeCorps.ModelCase

alias CodeCorps.StripeExternalAccount

@valid_attrs %{account_id_from_stripe: "some content", id_from_stripe: "some content"}
@invalid_attrs %{}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the comment below, can probably use less attrs here for it to be valid.


test "changeset with valid attributes" do
changeset = StripeExternalAccount.changeset(%StripeExternalAccount{}, @valid_attrs)
assert changeset.valid?
end

test "changeset with invalid attributes" do
changeset = StripeExternalAccount.changeset(%StripeExternalAccount{}, @invalid_attrs)
refute changeset.valid?
end
end
29 changes: 29 additions & 0 deletions web/models/stripe_external_account.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule CodeCorps.StripeExternalAccount do
use CodeCorps.Web, :model

schema "stripe_external_accounts" do
field :id_from_stripe, :string, null: false
field :account_id_from_stripe, :string, null: false
field :account_holder_name, :string
field :account_holder_type, :string
field :bank_name, :string
field :country, :string
field :currency, :string
field :default_for_currency, :string
field :fingerprint, :string
field :last4, :string
field :routing_number, :string
field :status, :string

timestamps()
end

@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:id_from_stripe, :account_id_from_stripe, :account_holder_name, :account_holder_type, :bank_name, :country, :currency, :default_for_currency, :fingerprint, :last4, :routing_number, :status])
|> validate_required([:id_from_stripe, :account_id_from_stripe])
end
end