Skip to content

Commit

Permalink
Merge pull request #378 from chatiti/master
Browse files Browse the repository at this point in the history
feat:Faker for Bank
  • Loading branch information
brianvoe authored Feb 13, 2025
2 parents 885f28c + 4c3ff5d commit c75ce9e
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ AchRouting() string
AchAccount() string
BitcoinAddress() string
BitcoinPrivateKey() string
BankName() string
BankType() string
```

### Finance
Expand Down Expand Up @@ -873,4 +875,4 @@ Song() *SongInfo
SongName() string
SongArtist() string
SongGenre() string
```
```
67 changes: 67 additions & 0 deletions data/bank.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package data

var Bank = map[string][]string{
"name": {
"Agricultural Bank of China",
"BNP Paribas",
"Banco Bilbao Vizcaya Argentaria",
"Banco Santander",
"Bank of America",
"Bank of China",
"Bank of Communications",
"Barclays",
"Capital One Financial Corporation",
"China Citic Bank",
"China Construction Bank Corporation",
"China Everbright Bank",
"China Merchants Bank",
"China Minsheng Bank",
"Citigroup",
"Commonwealth Bank Group",
"Credit Agricole Group",
"Credit Mutuel",
"Deutsche Bank",
"Goldman Sachs",
"Groupe BPCE",
"HDFC Bank",
"HSBC Holdings",
"Hua Xia Bank",
"ING Group",
"Industrial Bank",
"Industrial and Commercial Bank of China",
"Intesa Sanpaolo",
"JP Morgan Chase & Co",
"Lloyds Banking Group",
"Mitsubishi UFJ Financial Group",
"Mizuho Financial Group",
"Morgan Stanley",
"PNC Financial Services Group",
"Ping An Bank",
"Postal Savings Bank of China",
"Rabobank Group",
"Royal Bank of Canada",
"Sberbank",
"Scotiabank",
"Shanghai Pudong Development Bank",
"Societe Generale",
"State Bank of India",
"Sumitomo Mitsui Financial Group",
"Toronto Dominion Bank",
"Truist Bank",
"UBS",
"US Bancorp",
"UniCredit",
"Wells Fargo & Co",
},
"type": {
"Central Bank",
"Commercial Bank",
"Cooperative Bank",
"Investment Bank",
"Online Bank",
"Policy Bank",
"Private Bank",
"Retail Bank",
"Savings Bank",
},
}
1 change: 1 addition & 0 deletions data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var Data = map[string]map[string][]string{
"school": School,
"song": Songs,
"product": Product,
"bank": Bank,
}

func List() map[string][]string {
Expand Down
34 changes: 34 additions & 0 deletions payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ func bitcoinPrivateKey(f *Faker) string {
return "5" + randomString(f, []string{"H", "J", "K"}) + b.String()
}

func BankName() string { return bankName(GlobalFaker) }

func (f *Faker) BankName() string { return bankName(f) }

func bankName(f *Faker) string { return getRandValue(f, []string{"bank", "name"}) }

func BankType() string { return bankType(GlobalFaker) }

func (f *Faker) BankType() string { return bankType(f) }

func bankType(f *Faker) string { return getRandValue(f, []string{"bank", "type"}) }

func addPaymentLookup() {
AddFuncLookup("currency", Info{
Display: "Currency",
Expand Down Expand Up @@ -440,4 +452,26 @@ func addPaymentLookup() {
return bitcoinPrivateKey(f), nil
},
})

AddFuncLookup("bankname", Info{
Display: "Bank Name",
Category: "payment",
Description: "Name of a financial institution that offers banking services",
Example: "Wells Fargo",
Output: "string",
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
return bankName(f), nil
},
})

AddFuncLookup("banktype", Info{
Display: "Bank Type",
Category: "payment",
Description: "Classification of a bank based on its services and operations",
Example: "Investment Bank",
Output: "string",
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
return bankType(f), nil
},
})
}
40 changes: 40 additions & 0 deletions payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,43 @@ func BenchmarkBitcoinPrivateKey(b *testing.B) {
BitcoinPrivateKey()
}
}

func ExampleBankName() {
Seed(11)
fmt.Println(BankName())

// Output: Toronto Dominion Bank
}

func ExampleFaker_BankName() {
f := New(11)
fmt.Println(f.BankName())

// Output: Toronto Dominion Bank
}

func BenchmarkBankName(b *testing.B) {
for i := 0; i < b.N; i++ {
BankName()
}
}

func ExampleBankType() {
Seed(11)
fmt.Println(BankType())

// Output: Savings Bank
}

func ExampleFaker_BankType() {
f := New(11)
fmt.Println(f.BankType())

// Output: Savings Bank
}

func BenchmarkBankType(b *testing.B) {
for i := 0; i < b.N; i++ {
BankType()
}
}

0 comments on commit c75ce9e

Please sign in to comment.