Skip to content

Commit c75ce9e

Browse files
authored
Merge pull request #378 from chatiti/master
feat:Faker for Bank
2 parents 885f28c + 4c3ff5d commit c75ce9e

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ AchRouting() string
679679
AchAccount() string
680680
BitcoinAddress() string
681681
BitcoinPrivateKey() string
682+
BankName() string
683+
BankType() string
682684
```
683685

684686
### Finance
@@ -873,4 +875,4 @@ Song() *SongInfo
873875
SongName() string
874876
SongArtist() string
875877
SongGenre() string
876-
```
878+
```

data/bank.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package data
2+
3+
var Bank = map[string][]string{
4+
"name": {
5+
"Agricultural Bank of China",
6+
"BNP Paribas",
7+
"Banco Bilbao Vizcaya Argentaria",
8+
"Banco Santander",
9+
"Bank of America",
10+
"Bank of China",
11+
"Bank of Communications",
12+
"Barclays",
13+
"Capital One Financial Corporation",
14+
"China Citic Bank",
15+
"China Construction Bank Corporation",
16+
"China Everbright Bank",
17+
"China Merchants Bank",
18+
"China Minsheng Bank",
19+
"Citigroup",
20+
"Commonwealth Bank Group",
21+
"Credit Agricole Group",
22+
"Credit Mutuel",
23+
"Deutsche Bank",
24+
"Goldman Sachs",
25+
"Groupe BPCE",
26+
"HDFC Bank",
27+
"HSBC Holdings",
28+
"Hua Xia Bank",
29+
"ING Group",
30+
"Industrial Bank",
31+
"Industrial and Commercial Bank of China",
32+
"Intesa Sanpaolo",
33+
"JP Morgan Chase & Co",
34+
"Lloyds Banking Group",
35+
"Mitsubishi UFJ Financial Group",
36+
"Mizuho Financial Group",
37+
"Morgan Stanley",
38+
"PNC Financial Services Group",
39+
"Ping An Bank",
40+
"Postal Savings Bank of China",
41+
"Rabobank Group",
42+
"Royal Bank of Canada",
43+
"Sberbank",
44+
"Scotiabank",
45+
"Shanghai Pudong Development Bank",
46+
"Societe Generale",
47+
"State Bank of India",
48+
"Sumitomo Mitsui Financial Group",
49+
"Toronto Dominion Bank",
50+
"Truist Bank",
51+
"UBS",
52+
"US Bancorp",
53+
"UniCredit",
54+
"Wells Fargo & Co",
55+
},
56+
"type": {
57+
"Central Bank",
58+
"Commercial Bank",
59+
"Cooperative Bank",
60+
"Investment Bank",
61+
"Online Bank",
62+
"Policy Bank",
63+
"Private Bank",
64+
"Retail Bank",
65+
"Savings Bank",
66+
},
67+
}

data/data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var Data = map[string]map[string][]string{
3333
"school": School,
3434
"song": Songs,
3535
"product": Product,
36+
"bank": Bank,
3637
}
3738

3839
func List() map[string][]string {

payment.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,18 @@ func bitcoinPrivateKey(f *Faker) string {
240240
return "5" + randomString(f, []string{"H", "J", "K"}) + b.String()
241241
}
242242

243+
func BankName() string { return bankName(GlobalFaker) }
244+
245+
func (f *Faker) BankName() string { return bankName(f) }
246+
247+
func bankName(f *Faker) string { return getRandValue(f, []string{"bank", "name"}) }
248+
249+
func BankType() string { return bankType(GlobalFaker) }
250+
251+
func (f *Faker) BankType() string { return bankType(f) }
252+
253+
func bankType(f *Faker) string { return getRandValue(f, []string{"bank", "type"}) }
254+
243255
func addPaymentLookup() {
244256
AddFuncLookup("currency", Info{
245257
Display: "Currency",
@@ -440,4 +452,26 @@ func addPaymentLookup() {
440452
return bitcoinPrivateKey(f), nil
441453
},
442454
})
455+
456+
AddFuncLookup("bankname", Info{
457+
Display: "Bank Name",
458+
Category: "payment",
459+
Description: "Name of a financial institution that offers banking services",
460+
Example: "Wells Fargo",
461+
Output: "string",
462+
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
463+
return bankName(f), nil
464+
},
465+
})
466+
467+
AddFuncLookup("banktype", Info{
468+
Display: "Bank Type",
469+
Category: "payment",
470+
Description: "Classification of a bank based on its services and operations",
471+
Example: "Investment Bank",
472+
Output: "string",
473+
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
474+
return bankType(f), nil
475+
},
476+
})
443477
}

payment_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,43 @@ func BenchmarkBitcoinPrivateKey(b *testing.B) {
331331
BitcoinPrivateKey()
332332
}
333333
}
334+
335+
func ExampleBankName() {
336+
Seed(11)
337+
fmt.Println(BankName())
338+
339+
// Output: Toronto Dominion Bank
340+
}
341+
342+
func ExampleFaker_BankName() {
343+
f := New(11)
344+
fmt.Println(f.BankName())
345+
346+
// Output: Toronto Dominion Bank
347+
}
348+
349+
func BenchmarkBankName(b *testing.B) {
350+
for i := 0; i < b.N; i++ {
351+
BankName()
352+
}
353+
}
354+
355+
func ExampleBankType() {
356+
Seed(11)
357+
fmt.Println(BankType())
358+
359+
// Output: Savings Bank
360+
}
361+
362+
func ExampleFaker_BankType() {
363+
f := New(11)
364+
fmt.Println(f.BankType())
365+
366+
// Output: Savings Bank
367+
}
368+
369+
func BenchmarkBankType(b *testing.B) {
370+
for i := 0; i < b.N; i++ {
371+
BankType()
372+
}
373+
}

0 commit comments

Comments
 (0)