File: bank_parameter_data.go

package info (click to toggle)
golang-github-mitch000001-go-hbci 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,468 kB
  • sloc: java: 1,092; makefile: 5
file content (37 lines) | stat: -rw-r--r-- 1,282 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package domain

// BankParameterData represent metadata prvided by a bank institute that
// reflect limitations and limits when talking to that institute
type BankParameterData struct {
	Version                    int
	BankID                     BankID          `yaml:",inline"`
	BankName                   string          `yaml:"bankName"`
	MaxTransactionsPerMessage  int             `yaml:"maxTransactionsPerMessage"`
	MaxMessageSize             int             `yaml:"maxMessageSize"`
	MinTimeout                 int             `yaml:"minTimeout"`
	MaxTimeout                 int             `yaml:"maxTimeout"`
	PinTanBusinessTransactions map[string]bool `yaml:"pinTanBusinessTransactions"`
}

// PinTanBusinessTransaction provides information about whether a given Segment
// needs a TAN or not.
type PinTanBusinessTransaction struct {
	SegmentID string `yaml:"segmentID"`
	NeedsTan  bool   `yaml:"needsTan"`
}

type PinTanBusinessTransactions []PinTanBusinessTransaction

func (p PinTanBusinessTransactions) NeedsTan(segmentID string) (bool, bool) {
	var transaction *PinTanBusinessTransaction
	for _, tr := range p {
		if tr.SegmentID == segmentID {
			transaction = &tr
			break
		}
	}
	if transaction == nil {
		return false, false
	}
	return transaction.NeedsTan, true
}