From 368225f3317935e1178b79d580e45d2ac357dd84 Mon Sep 17 00:00:00 2001 From: Danylo Negrienko Date: Tue, 5 Mar 2024 19:56:59 -0500 Subject: [PATCH] List deserializer added --- lib/iban_ex/deserialize.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/iban_ex/deserialize.ex b/lib/iban_ex/deserialize.ex index 62679f4..38b4e70 100644 --- a/lib/iban_ex/deserialize.ex +++ b/lib/iban_ex/deserialize.ex @@ -27,6 +27,8 @@ defimpl IbanEx.Deserialize, for: Map do country_code: _country_code, check_digits: _check_sum_digits, bank_code: _bank_code, + branch_code: _branch_code, + national_check: _national_check, account_number: _account_number } = map ) do @@ -38,6 +40,8 @@ defimpl IbanEx.Deserialize, for: Map do "country_code" => _country_code, "check_digits" => _check_sum_digits, "bank_code" => _bank_code, + "branch_code" => _branch_code, + "national_check" => _national_check, "account_number" => _account_number } = map ) do @@ -47,3 +51,11 @@ defimpl IbanEx.Deserialize, for: Map do def to_iban(map) when is_map(map), do: {:error, :can_not_parse_map} end + +defimpl IbanEx.Deserialize, for: List do + alias IbanEx.Iban + @type iban_or_error() :: IbanEx.Iban.t() | {:error, :can_not_parse_map} + + @spec to_iban(list()) :: iban_or_error() + def to_iban(list), do: struct(Iban, Map.new(list)) +end