File: user_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 (150 lines) | stat: -rw-r--r-- 5,427 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package segment

import (
	"github.com/mitch000001/go-hbci/domain"
	"github.com/mitch000001/go-hbci/element"
)

const CommonUserParameterDataID string = "HIUPA"

//go:generate go run ../cmd/unmarshaler/unmarshaler_generator.go -segment CommonUserParameterDataSegment -segment_interface commonUserParameterDataSegment -segment_versions="CommonUserParameterDataV2:2:Segment,CommonUserParameterDataV3:3:Segment,CommonUserParameterDataV4:4:Segment"

type CommonUserParameterData interface {
	BankSegment
	UserParameterData() domain.UserParameterData
}

type CommonUserParameterDataSegment struct {
	commonUserParameterDataSegment
}

type commonUserParameterDataSegment interface {
	BankSegment
	UserParameterData() domain.UserParameterData
}

type CommonUserParameterDataV2 struct {
	Segment
	UserID     *element.IdentificationDataElement
	UPDVersion *element.NumberDataElement
	// Status |Beschreibung
	// -----------------------------------------------------------------
	// 0	  | Die nicht aufgeführten Geschäftsvorfälle sind gesperrt
	//		  | (die aufgeführten Geschäftsvorfälle sind zugelassen).
	// 1    | Bei den nicht aufgeführten Geschäftsvorfällen ist anhand
	//        | der UPD keine Aussage darüber möglich, ob diese erlaubt
	//        | oder gesperrt sind. Diese Prüfung kann nur online vom
	//        | Kreditinstitutssystem vorgenommen werden.
	UPDUsage *element.NumberDataElement
}

func (c *CommonUserParameterDataV2) Version() int         { return 2 }
func (c *CommonUserParameterDataV2) ID() string           { return CommonUserParameterDataID }
func (c *CommonUserParameterDataV2) referencedId() string { return ProcessingPreparationID }
func (c *CommonUserParameterDataV2) sender() string       { return senderBank }

func (c *CommonUserParameterDataV2) elements() []element.DataElement {
	return []element.DataElement{
		c.UserID,
		c.UPDVersion,
		c.UPDUsage,
	}
}

func (c *CommonUserParameterDataV2) UserParameterData() domain.UserParameterData {
	return domain.UserParameterData{
		UserID:  c.UserID.Val(),
		Version: c.UPDVersion.Val(),
		Usage:   c.UPDUsage.Val(),
	}
}

type CommonUserParameterDataV3 struct {
	Segment
	UserID     *element.IdentificationDataElement
	UPDVersion *element.NumberDataElement
	// Status |Beschreibung
	// -----------------------------------------------------------------
	// 0	  | Die nicht aufgeführten Geschäftsvorfälle sind gesperrt
	//		  | (die aufgeführten Geschäftsvorfälle sind zugelassen).
	// 1    | Bei den nicht aufgeführten Geschäftsvorfällen ist anhand
	//        | der UPD keine Aussage darüber möglich, ob diese erlaubt
	//        | oder gesperrt sind. Diese Prüfung kann nur online vom
	//        | Kreditinstitutssystem vorgenommen werden.
	UPDUsage         *element.NumberDataElement
	UserName         *element.AlphaNumericDataElement
	CommonExtensions *element.AlphaNumericDataElement
}

func (c *CommonUserParameterDataV3) Version() int         { return 3 }
func (c *CommonUserParameterDataV3) ID() string           { return CommonUserParameterDataID }
func (c *CommonUserParameterDataV3) referencedId() string { return ProcessingPreparationID }
func (c *CommonUserParameterDataV3) sender() string       { return senderBank }

func (c *CommonUserParameterDataV3) elements() []element.DataElement {
	return []element.DataElement{
		c.UserID,
		c.UPDVersion,
		c.UPDUsage,
		c.UserName,
		c.CommonExtensions,
	}
}

func (c *CommonUserParameterDataV3) UserParameterData() domain.UserParameterData {
	return domain.UserParameterData{
		UserID:  c.UserID.Val(),
		Version: c.UPDVersion.Val(),
		Usage:   c.UPDUsage.Val(),
	}
}

type CommonUserParameterDataV4 struct {
	Segment
	UserID     *element.IdentificationDataElement
	UPDVersion *element.NumberDataElement
	// Status |Beschreibung
	// -----------------------------------------------------------------
	// 0	  | Die nicht aufgeführten Geschäftsvorfälle sind gesperrt
	//		  | (die aufgeführten Geschäftsvorfälle sind zugelassen).
	// 1    | Bei den nicht aufgeführten Geschäftsvorfällen ist anhand
	//        | der UPD keine Aussage darüber möglich, ob diese erlaubt
	//        | oder gesperrt sind. Diese Prüfung kann nur online vom
	//        | Kreditinstitutssystem vorgenommen werden.
	UPDUsage         *element.NumberDataElement
	UserName         *element.AlphaNumericDataElement
	CommonExtensions *element.AlphaNumericDataElement
}

func (c *CommonUserParameterDataV4) Version() int         { return 4 }
func (c *CommonUserParameterDataV4) ID() string           { return CommonUserParameterDataID }
func (c *CommonUserParameterDataV4) referencedId() string { return ProcessingPreparationID }
func (c *CommonUserParameterDataV4) sender() string       { return senderBank }

func (c *CommonUserParameterDataV4) elements() []element.DataElement {
	return []element.DataElement{
		c.UserID,
		c.UPDVersion,
		c.UPDUsage,
		c.UserName,
		c.CommonExtensions,
	}
}

func (c *CommonUserParameterDataV4) UserParameterData() domain.UserParameterData {
	var username string
	if c.UserName != nil {
		username = c.UserName.Val()
	}
	var additions string
	if c.CommonExtensions != nil {
		additions = c.CommonExtensions.Val()
	}
	return domain.UserParameterData{
		UserID:    c.UserID.Val(),
		Version:   c.UPDVersion.Val(),
		Usage:     c.UPDUsage.Val(),
		UserName:  username,
		Additions: additions,
	}
}