-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from razorpay/go-src
- Loading branch information
Showing
19 changed files
with
3,944 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: bundler | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: bundler | ||
directory: "/scraper" | ||
schedule: | ||
interval: daily | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: mix | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: composer | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: bundler | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: bundler | ||
directory: "/scraper" | ||
schedule: | ||
interval: weekly | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: mix | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: composer | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
time: "04:00" | ||
timezone: Asia/Calcutta | ||
- package-ecosystem: gomod | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
time: "04:00" | ||
timezone: Asia/Calcutta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,9 @@ InstalledFiles | |
|
||
# One-off scripts | ||
*.php | ||
|
||
# IDE files | ||
.idea/* | ||
|
||
# Temp files | ||
.*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
go-test: | ||
go test -tags=unit -timeout 2m -coverprofile=coverage.cov -v ./... | ||
|
||
generate-constants: | ||
go run ./src/go/generator/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/razorpay/ifsc | ||
|
||
go 1.15 | ||
|
||
require github.com/stretchr/testify v1.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ifsc | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
) | ||
|
||
type Bank struct { | ||
Name string `json:"name"` | ||
BankCode string `json:"bank_code"` | ||
Code string `json:"code"` | ||
Type string `json:"type"` | ||
IFSC string `json:"ifsc"` | ||
MICR string `json:"micr"` | ||
IIN string `json:"iin"` | ||
APBS bool `json:"apbs"` | ||
AchCredit bool `json:"ach_credit"` | ||
AchDebit bool `json:"ach_debit"` | ||
NachDebit bool `json:"nach_debit"` | ||
Upi bool `json:"upi",omitempty` | ||
} | ||
|
||
var bankData map[string]Bank | ||
|
||
func LoadBankData() { | ||
if bankData == nil { | ||
if err := LoadFile("banks.json", &bankData, ""); err != nil { | ||
log.Panic(fmt.Sprintf("there is some error in banknames.json file: %v", err)) | ||
} | ||
} | ||
} | ||
|
||
func GetBankDetails(bankCode string) *Bank { | ||
data, ok := bankData[bankCode] | ||
if !ok { | ||
return nil | ||
} | ||
var err error | ||
data.Name, err = GetBankName(bankCode) | ||
if err != nil { | ||
return nil | ||
} | ||
if data.MICR != "" { | ||
data.BankCode = data.MICR[3:6] | ||
} | ||
return &data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ifsc | ||
|
||
import ( | ||
"testing" | ||
// TODO: change | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_BankGetDetails(t *testing.T) { | ||
assert := assert.New(t) | ||
result := GetBankDetails("FINO") | ||
assert.Equal(getFINOfixture(), *result) | ||
result = GetBankDetails("PUNB") | ||
assert.Equal(getPUNBFixture(), *result) | ||
} | ||
func getPUNBFixture() Bank { | ||
return Bank{ | ||
Name: "Punjab National Bank", | ||
BankCode: "024", | ||
Code: "PUNB", | ||
Type: "PSB", | ||
IFSC: "PUNB0244200", | ||
MICR: "110024001", | ||
IIN: "508568", | ||
APBS: true, | ||
AchCredit: true, | ||
AchDebit: true, | ||
NachDebit: true, | ||
Upi: true, | ||
} | ||
} | ||
func getFINOfixture() Bank { | ||
return Bank{ | ||
Name: "Fino Payments Bank", | ||
BankCode: "", | ||
Code: "FINO", | ||
Type: "PB", | ||
IFSC: "FINO0000001", | ||
MICR: "", | ||
IIN: "608001", | ||
APBS: true, | ||
AchCredit: true, | ||
AchDebit: false, | ||
NachDebit: false, | ||
Upi: true, | ||
} | ||
} |
Oops, something went wrong.