| 1 | package bankinfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 5 | "mathscip-go gomod github.com/golang/go/src go1.18 math/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 7 | ) |
| 8 | |
| 9 | const ( |
| 10 | version210scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version210. = "2.1" |
| 11 | version220scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version220. = "2.2" |
| 12 | version300scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version300. = "3.0" |
| 13 | version400scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version400. = "4.0" |
| 14 | version410scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version410. = "4.1" |
| 15 | versionString220scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString220. = "HBCI 2.2 Erweiterung PIN/TAN V1.01" |
| 16 | versionString300scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString300. = "FinTS V3.0" |
| 17 | versionString400scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString400. = "FinTS V4.0" |
| 18 | versionString410scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString410. = "FinTS V4.1" |
| 19 | ) |
| 20 | |
| 21 | // FindByBankID returns the BankInfo found for the provided bankID. If no value |
| 22 | // is found an zero value is returned. |
| 23 | func FindByBankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/FindByBankID().(bankID string) BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo# { |
| 24 | var bankInfo BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo# |
| 25 | for _, entry := range datascip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/data. { |
| 26 | if entry.BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID. == bankID { |
| 27 | bankInfo = entry |
| 28 | } |
| 29 | } |
| 30 | return bankInfo |
| 31 | } |
| 32 | |
| 33 | // BankInfo contains information about the HBCI settings and supported version |
| 34 | // of a given bank institute. The institute is referenced by its BankID. |
| 35 | type BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo# struct { |
| 36 | BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID. string |
| 37 | BICscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BIC. string |
| 38 | VersionNumberscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionNumber. string |
| 39 | URLscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#URL. string |
| 40 | VersionNamescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionName. string |
| 41 | Institutescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#Institute. string |
| 42 | Cityscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#City. string |
| 43 | LastChangedscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#LastChanged. string |
| 44 | } |
| 45 | |
| 46 | // HbciVersion tries to parse the HBCI version out of VersionName and |
| 47 | // VersionNumber. It panics if there is any error while getting a version out |
| 48 | // of the name or the number. |
| 49 | // |
| 50 | // The returned number will be a 3 digit integer, like 200, 210, 220, 300, 400. |
| 51 | func (b BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#) HbciVersionscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#HbciVersion().() int { |
| 52 | version, err := hbciVersionscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/hbciVersion().(b.VersionNamescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionName., b.VersionNumberscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#VersionNumber.) |
| 53 | if err != nil { |
| 54 | panic(err) |
| 55 | } |
| 56 | return version |
| 57 | } |
| 58 | |
| 59 | // SortableBankInfos implements the sort.Interface |
| 60 | type SortableBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos# []BankInfoscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo# |
| 61 | |
| 62 | func (s SortableBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#) Lenscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#Len().() int { return len(s) } |
| 63 | func (s SortableBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#) Swapscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#Swap().(a, b int) { s[a], s[b] = s[b], s[a] } |
| 64 | func (s SortableBankInfosscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#) Lessscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/SortableBankInfos#Less().(a, b int) bool { return s[a].BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID. < s[b].BankIDscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/BankInfo#BankID. } |
| 65 | |
| 66 | func hbciVersionscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/hbciVersion().(versionName, versionNumber string) (int, error) { |
| 67 | var errs []string |
| 68 | parsedVersionName, err := parseVersionNamescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/parseVersionName().(versionName) |
| 69 | if err != nil { |
| 70 | errs = append(errs, err.Error()) |
| 71 | } |
| 72 | parsedVersionNumber, err := parseVersionNumberscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/parseVersionNumber().(versionNumber) |
| 73 | if err != nil { |
| 74 | errs = append(errs, err.Error()) |
| 75 | } |
| 76 | if len(errs) != 0 { |
| 77 | return 0, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Joinscip-go gomod github.com/golang/go/src go1.18 strings/Join().(errs, "\n")) |
| 78 | } |
| 79 | return int(mathscip-go gomod github.com/golang/go/src go1.18 math/.Maxscip-go gomod github.com/golang/go/src go1.18 math/Max().(float64(parsedVersionNumber), float64(parsedVersionName))), nil |
| 80 | } |
| 81 | |
| 82 | func parseVersionNamescip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/parseVersionName().(versionName string) (int, error) { |
| 83 | switch versionName { |
| 84 | case versionString220scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString220.: |
| 85 | return 220, nil |
| 86 | case versionString300scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString300.: |
| 87 | return 300, nil |
| 88 | case versionString400scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString400.: |
| 89 | return 400, nil |
| 90 | case versionString410scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/versionString410.: |
| 91 | return 410, nil |
| 92 | case "": |
| 93 | return -1, nil |
| 94 | default: |
| 95 | return 0, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("Unknown HBCI Version Name: %q", versionName) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | func parseVersionNumberscip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/parseVersionNumber().(versionNumber string) (int, error) { |
| 100 | switch versionNumber { |
| 101 | case version210scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version210.: |
| 102 | return 210, nil |
| 103 | case version220scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version220.: |
| 104 | return 220, nil |
| 105 | case version300scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version300.: |
| 106 | return 300, nil |
| 107 | case version400scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version400.: |
| 108 | return 400, nil |
| 109 | case version410scip-go gomod github.com/mitch000001/go-hbci . `github.com/mitch000001/go-hbci/bankinfo`/version410.: |
| 110 | return 410, nil |
| 111 | case "": |
| 112 | return -1, nil |
| 113 | default: |
| 114 | return 0, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("Unknown HBCI Version Number: %q", versionNumber) |
| 115 | } |
| 116 | } |