Skip to content

Commit

Permalink
add tbd fees (#10)
Browse files Browse the repository at this point in the history
* add tbd fees

* add hans as codeowner

* nil values in empty amount rather than tbd
  • Loading branch information
coburncoburn authored Sep 19, 2022
1 parent b07969c commit 3fce2da
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @aryanbhasin @coburncoburn @hayesgm
* @aryanbhasin @coburncoburn @hayesgm @cwang25
7 changes: 7 additions & 0 deletions lib/circlex/struct/amount.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ defmodule Circlex.Struct.Amount do

defstruct [:amount, :currency]

def deserialize(nil) do
%__MODULE__{
amount: nil,
currency: nil
}
end

def deserialize(amount) do
%__MODULE__{
amount: fetch(amount, :amount),
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Circlex.MixProject do
def project do
[
app: :circlex_api,
version: "0.1.10",
version: "0.1.11",
elixir: "~> 1.13",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
7 changes: 7 additions & 0 deletions test/circlex/struct/payout_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ defmodule Circlex.Struct.PayoutTest do
}

@payout_ser_with_external_ref Map.put(@payout_ser, :externalRef, "ext_ref")
@payout_ser_without_fees Map.delete(@payout_ser, :fees)

describe "deserialize" do
test "with external ref" do
Expand All @@ -50,6 +51,12 @@ defmodule Circlex.Struct.PayoutTest do
test "without external ref" do
assert Payout.deserialize(@payout_ser) == @payout
end

test "without fees" do
assert Payout.deserialize(@payout_ser_without_fees) ==
@payout
|> Map.put(:fees, %Circlex.Struct.Amount{amount: nil, currency: nil})
end
end

describe "serialize" do
Expand Down

0 comments on commit 3fce2da

Please sign in to comment.