Skip to content

Commit c567fb0

Browse files
committed
add get/1 function to get single bank given its bank_code
1 parent 8b79bc5 commit c567fb0

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

lib/bundesbank.ex

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
defmodule Bundesbank do
2-
@moduledoc ~S"""
3-
A collection of German Bank Data including BIC, Bankcodes, PAN and more useful information based on the [Bundesbank Data Set](https://www.bundesbank.de/de/aufgaben/unbarer-zahlungsverkehr/serviceangebot/bankleitzahlen/download-bankleitzahlen-602592)
2+
@moduledoc ~S"""
3+
A collection of German Bank Data including BIC, Bankcodes, PAN and more useful information based on the [Bundesbank Data Set](https://www.bundesbank.de/de/aufgaben/unbarer-zahlungsverkehr/serviceangebot/bankleitzahlen/download-bankleitzahlen-602592)
44
5-
**Current Data Set is Valid until September, 06th 2020**
5+
**Current Data Set is Valid until September, 06th 2020**
66
"""
77

88
@doc """
@@ -12,6 +12,19 @@ defmodule Bundesbank do
1212
bundesbank()
1313
end
1414

15+
@doc """
16+
Returns one bank given its code
17+
## Examples
18+
iex> %Bundesbank.Bank{bank_name: bank_name} = Bundesbank.get(50010060)
19+
iex> bank_name
20+
"Postbank Ndl DB PFK"
21+
"""
22+
23+
def get(code) do
24+
[bank] = filter_by(:code, code)
25+
bank
26+
end
27+
1528
@doc """
1629
Filters banks by given key.
1730

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule Bundesbank.MixProject do
1414
name: "Bundesbank",
1515
source_url: "https://github.com/daskycodes/bundesbank",
1616
deps: deps(),
17-
docs: docs(),
17+
docs: docs()
1818
]
1919
end
2020

test/bundesbank_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ defmodule BundesbankTest do
99
end
1010
end
1111

12+
describe "get/1" do
13+
test "gets one bank" do
14+
%{code: "50010060"} = Bundesbank.get(50010060)
15+
end
16+
end
17+
1218
describe "exists?/2" do
1319
test "checks if bank exists" do
1420
refute Bundesbank.exists?(:city, "New York")

0 commit comments

Comments
 (0)